Created
June 18, 2024 18:50
-
-
Save BenjaminSantiago/293203344ced7b58d055d6ae7e0c1e3f to your computer and use it in GitHub Desktop.
drawbot code in python used for text animation in this video: https://www.youtube.com/watch?v=3vzk5T6-oS8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#DUNKY DONEY YY Y Y Y Y | |
''' | |
This will make a lil animation where a piece of | |
text will animate one axis of a variable font | |
"across" a piece of text | |
''' | |
# parameters to change | |
# -------------------------- | |
words = "DONEY" | |
FRAMESperLETTER = 7 | |
FRAMES = len(words) * FRAMESperLETTER | |
# -------------------------- | |
# function for offset angle | |
''' | |
this function just takes a value from 0 - 1 that we | |
assume we will use for rotation and then apply it to | |
a new range | |
''' | |
# ---------------------------------------------------------- | |
def offset(min_value, max_value, curr_angle): | |
return min_value + (sin(curr_angle * pi)) * (max_value-min_value) | |
# ---------------------------------------------------------- | |
# generate FRAMES our BIG LOOP | |
# ---------------------------------------------------------- | |
for frame in range(FRAMES): | |
# get the Current Letter (not an integer) | |
cl = frame/FRAMESperLETTER | |
# this gives us a normalized value | |
# but PER LETTER (0-1 repeating for each letter) | |
# (not used) | |
cln = frame%FRAMESperLETTER | |
# set up our string and "page" | |
msg = FormattedString() | |
newPage(1920, 1080) | |
frameDuration(1 / 30) | |
cmykFill(0, 0, 0, 0) | |
# "frames normalized" | |
# value from 0 - 1 for ALL of our frames | |
fn = frame / FRAMES | |
# kinda kudgled value, as I'm not sure what is happening exactly below | |
# this gives us a range for the axis below, but had to make it higher | |
# than 900 to make it get to 900 | |
ov = offset(100, 1200, fn) | |
# go through each letter | |
for li in range(len(words)): | |
# "normalized" value of letter per string | |
# for the "current" letter | |
fi = li/len(words) | |
# this will give us the DISTANCE from the current letter | |
# I add 1 so that we aren't dividing by zero anywhere | |
d = 1+(abs(li-cl)) | |
# font properties | |
the_font = "PurpleHaze-Thin_Black-Unispace" | |
the_tracking = 70 | |
the_font_size = 300 | |
the_line_height = 150 | |
the_variability = ov*(1/d) | |
# put the properties into the string | |
msg.append( | |
words[li], | |
font=the_font, | |
tracking=the_tracking, | |
fontSize=the_font_size, | |
lineHeight=the_line_height, | |
fontVariations=dict(wtsp=700,wtun=the_variability)) | |
#give us our string | |
text(msg, (width() / 2, 400), align="center") | |
# ---------------------------------------------------------- | |
# OUTPUT to PNG sequence (for transparency) | |
saveImage("DONEY/DONEY.png", multipage="true") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment