User:Lidia.Pereira/PNM/Rawgif
< User:Lidia.Pereira | PNM
import struct, sys
import random
width = 320
height = 240
header = struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 8, 0, 0, width, height, 32, 1 << 5)
totalFrames = 25
largeColumns = (width/5) - 25
smallColumns = 25
for frame in xrange(totalFrames):
out = open("frame%04d.tga" % frame, "wb")
out.write(header)
attempt = random.randint(height/7, height/1.2)
attempt1 = random.randint(10,90)
cor = random.randint(55,255)
for y in xrange(height):
for x in xrange(5):
for n in xrange(largeColumns):
r, g, b, a = 0, 0, 0, 255
if y <= attempt:
r, g = 55, 255
b = (frame + 1) * 10
else:
r = 155
out.write(struct.pack('B', b))
out.write(struct.pack('B', g))
out.write(struct.pack('B', r))
out.write(struct.pack('B', a))
for x in xrange(smallColumns):
r, g, b, a = 0, 0, 0, 255
if y < attempt1:
b = 155
if y > attempt1 and y < 200:
b = cor
else:
b = 90
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()
The "unsuccessful" tries:
import struct, sys
import random
width = 320
height = 240
header = struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 8, 0, 0, width, height, 32, 1 << 5)
totalFrames = 25
largeColumns = (width/5) - 25
smallColumns = 25
for frame in xrange(totalFrames):
out = open("frame%04d.tga" % frame, "wb")
out.write(header)
attempt1 = random.randint(10,90)
cor = random.randint(55,255)
for y in xrange(height):
for x in xrange(5):
attempt = random.randint(height/7, height/1.2)
for n in xrange(largeColumns):
r, g, b, a = 0, 0, 0, 255
if y <= attempt:
r, g = 55, 255
b = (frame + 1) * 10
else:
r = 155
out.write(struct.pack('B', b))
out.write(struct.pack('B', g))
out.write(struct.pack('B', r))
out.write(struct.pack('B', a))
for x in xrange(smallColumns):
r, g, b, a = 0, 0, 0, 255
if y < attempt1:
b = 155
if y > attempt1 and y < 200:
b = cor
else:
b = 90
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()
import struct, sys
import random
width = 320
height = 240
header = struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 8, 0, 0, width, height, 32, 1 << 5)
totalFrames = 25
largeColumns = (width/5) - 25
smallColumns = 25
for frame in xrange(totalFrames):
out = open("frame%04d.tga" % frame, "wb")
out.write(header)
attempt1 = random.randint(10,90)
cor = random.randint(55,255)
for y in xrange(height):
for x in xrange(5):
for n in xrange(largeColumns):
attempt = random.randint(height/7, height/1.2)
r, g, b, a = 0, 0, 0, 255
if y <= attempt:
r, g = 55, 255
b = (frame + 1) * 10
else:
r = 155
out.write(struct.pack('B', b))
out.write(struct.pack('B', g))
out.write(struct.pack('B', r))
out.write(struct.pack('B', a))
for x in xrange(smallColumns):
r, g, b, a = 0, 0, 0, 255
if y < attempt1:
b = 155
if y > attempt1 and y < 200:
b = cor
else:
b = 90
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()