User:Mihail Bakalov/Trimester 1/NETWORK BASED PROTOTYPING/Assignment11.11.2013

From XPUB & Lens-Based wiki
< User:Mihail Bakalov‎ | Trimester 1‎ | NETWORK BASED PROTOTYPING
Revision as of 16:39, 15 January 2014 by Mihail Bakalov (talk | contribs) (Created page with "File:Mishopyanim.gif 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 f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Mishopyanim.gif

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()