Assignemt - 11.11.13: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
import struct, sys | import struct, sys | ||
width = 320 | width = 320 | ||
height = 240 | height = 240 | ||
header = struct.pack("<BBBHHBHHHHBB",0,0,2,0,0,8,0,0,width,height,32,1<<5) | header = struct.pack("<BBBHHBHHHHBB",0,0,2,0,0,8,0,0,width,height,32,1<<5) | ||
totalframes = 25 | totalframes = 25 | ||
for frame in xrange(totalframes): | for frame in xrange(totalframes): | ||
out = open("frame_%02d.tga" % frame, "wb") | out = open("frame_%02d.tga" % frame, "wb") |
Revision as of 00:44, 9 November 2013
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 y >= 200: r = 5*(float(frame)) g = y/4+2*(float(frame)) b = 3*(float(frame)) a = 255 elif y <= 75: r = (x+y)/4+(float(frame)/totalframes) g = y+2*(float(frame)) b = y+2*(float(frame)) a = 255 else: r = 5+5*(float(frame)/totalframes) g = y-2*(float(frame)) b = 4*(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()