Python code reveal: This is how I made my marquee for Leo Threads
(Edited)
I just made the GIF above and posted it Leo Threads.
For the back story, read my post advocating for the use of GIF as a way to present short contents on Leo Threads. I can't wait for Short Contents through some magical collaborations between Leo Finance and SPK, so I started researching on how GIF can be made and used instead.
By research, I also mean I ask ChatGPT how to create GIF using Python.
The GIF above is produced using the code below.
from PIL import Image, ImageDraw, ImageFont
import imageio
import urllib.request
import matplotlib.font_manager as fm
# font file path
font_path = 'Roboto-Black.ttf'
prop = fm.FontProperties(fname=font_path)
# the sentence to animate
sentence = "How do you like this as my thread? I think the marquee effect is great for this use case. Come on, give it some upvotes! Thank you!"
frames = []
# for each position in the range
for x in range(200, -100*len(sentence), -5):
# create a new image with a white background
image = Image.new('RGB', (200, 200), color = (0, 0, 0))
d = ImageDraw.Draw(image)
# specify the font, size
font = ImageFont.truetype(font_path, 30)
# add the text to the image at the given position
d.text((x, 90), sentence, fill=(255, 255, 255), font=font)
# append the image to the frames list
frames.append(image)
# create the gif
frames[0].save('animated_text.gif', format='GIF', append_images=frames[1:], save_all=True, duration=50, loop=0)
from google.colab import files
files.download('animated_text.gif')
Hope that is some use for you if you are keen to make your own GIFs. Better still, share your design ideas for making GIFs!
Posted Using LeoFinance Alpha
0
0
0.000
Congratulations @cryptothesis! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
Your next target is to reach 25000 upvotes.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts:
That is some nice code to use and it's simple because people only need to input the text. Did ChatGPT give you the code perfectly or did you have to change some things?
I think it’s as perfect as it can get. I just need to tweak the part on the font. !PIZZA
$PIZZA slices delivered:
@cryptothesis(1/15) tipped @jfang003
That's interesting, Is the whole code is written by CHATGPT? or do you have edit it?