image - Create an animated GIF file without PIL or other python add ons -
so i'm trying write program creates short animated gif of red cube bouncing left right. stuck, however, when comes saving images gif file, , i've searched everywhere can't seem figure out how accomplish without using pil or other add on. (the program class , cannot use such add ons)
the following code of now..i've been playing around lot of code used commented out.
# bouncingcube.py # program designed produce animated gif displaying red square bouncing , forth between left , right edges import tkinter tkinter import * import base64 root = tk() def fill_bg(image): r,g,b = (255,255,255) width = 110 height = 110 hexcode = "#%02x%02x%02x" % (r,g,b) horizontal_line = "{" + " ".join([hexcode]*width) + "}" image.put(" ".join([horizontal_line]*height)) def fill_box(image, color, pos): r,g,b = color width = 30 height = 30 x,y = pos hexcode = "#%02x%02x%02x" % (r,g,b) horizontal_line = "{" + " ".join([hexcode]*width) + "}" image.put(" ".join([horizontal_line]*height), (y,x)) = 0 while != 90: photo = photoimage(width=30, height=30) fill_bg(photo) fill_box(photo, (255,0,0), (40,i)) #label = tkinter.label(root, image=photo) #label.pack() = + 10 while != 0: photo = photoimage(width=30, height=30) fill_bg(photo) fill_box(photo, (255,0,0), (40,i)) #label = tkinter.label(root, image=photo) #label.pack() = - 10 #root.mainloop() any right direction appreciated, if it's different method 1 attempting use. much!!
Comments
Post a Comment