Last active
July 11, 2021 08:23
-
-
Save jeremypruitt/0e88d95e90019117d7059c0c42b4da1b to your computer and use it in GitHub Desktop.
Revisions
-
jeremypruitt revised this gist
Nov 19, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ $ python3 alice2.py Enter the low number of the range [10330]: Enter the high number of the range [10346]: 10999 How long to hold on each number [100]: 50 Enter the name of the animated gif to generate [incrementing-counter.gif]: Generated animated gif at ./incrementing-counter.gif -
jeremypruitt revised this gist
Nov 19, 2020 . 1 changed file with 20 additions and 35 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,42 +1,27 @@ from PIL import Image, ImageDraw, ImageSequence, ImageFont import io import click FIRST_NUMBER = click.prompt('Enter the low number of the range', default=10330, type=int) LAST_NUMBER = click.prompt('Enter the high number of the range', default=10346, type=int) FRAME_DURATION = click.prompt('How long to hold on each number', default=100, type=int) ANIMATED_GIF_FILENAME = click.prompt('Enter the name of the animated gif to generate', default="incrementing-counter.gif", type=str) TEXT_COLOR = (255,255,255) TEXT_SIZE = (5,-2) TEXT_BG_COLOR = (0,0,0) TEXT_BG_SIZE = (115,40) # Download: https://github.com/blaisck/sfwin/blob/master/SFPro/TrueType/SFProDisplay-Regular.ttf fnt = ImageFont.truetype("SFProDisplay-Regular.ttf", 36) frames = [] for count in list(range(FIRST_NUMBER, LAST_NUMBER)): new_img = Image.new('RGB', TEXT_BG_SIZE, TEXT_BG_COLOR) draw = ImageDraw.Draw(new_img) draw.text(TEXT_SIZE, str(count), font = fnt, fill=TEXT_COLOR) frames.append(new_img) frames[0].save(ANIMATED_GIF_FILENAME, format='GIF', append_images=frames[1:], save_all=True, duration=FRAME_DURATION, loop=0) print(f'Generated animated gif at ./{ANIMATED_GIF_FILENAME}') -
jeremypruitt created this gist
Nov 19, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ from PIL import Image, ImageDraw, ImageSequence, ImageFont import io ImageFont.load_default() def create_image_with_text(size, text): img = Image.new('RGB', (350, 50), (0,0,0)) draw = ImageDraw.Draw(img) draw.text((size[0], size[1]), text, font = fnt, fill=(255,255,255)) return img # Create the frames frames = [] # Rolling meant that it would add each number in the line as # a frame. We don't want that, but i didn't get rid of the # rolling yet as it is serving as a form of delay I think. # Once proper delays are added then can remove this def. def roll(text): for i in range(len(text)+1): new_frame = create_image_with_text((0,0), text) frames.append(new_frame) #fnt = ImageFont.truetype("arial", 36) fnt = ImageFont.load_default() # Each number gets a line all_text = """236,995 236,996 236,997 236,998 236,999 237,000""".splitlines() # To understand roll() see the definition [roll(text) for text in all_text] # Save into a GIF file that loops forever frames[0].save('incrementing-counter.gif', format='GIF', append_images=frames[1:], save_all=True, duration=80, loop=0) print("Done")