Raw gif
Revision as of 16:27, 8 December 2013 by Chen Junyu (talk | contribs) (Created page with "File:Rawgif-chen.gif ==raw== <source lang="python"> import struct, sys width = 320 height = 240 header = struct.pack("<BBBHHBHHHHBB",0,0,2,0,0,8,0,0,width,height,3...")
raw
import struct, sys
width = 320
height = 240
header = struct.pack("<BBBHHBHHHHBB",0,0,2,0,0,8,0,0,width,height,32,1<<5)
totalframes = 25
for frame in xrange(totalframes):
out = open("frame_%02d.tga" % frame, "wb")
out.write(header)
for y in xrange(height):
for x in xrange(width):
if x >= 120:
r = 0
g = 255*(1 - float(frame)/totalframes)
b = 143*(1 - float(frame)/totalframes)
a = 255
if x < 120:
r = 255*(float(frame)/totalframes)
g = 255
b = 255 - (112/25)*(float(frame))
a = 255
out.write(struct.pack('B', b))
out.write(struct.pack('B', g))
out.write(struct.pack('B', r))
out.write(struct.pack('B', a))
out.close()