User:FluffyDunlop/Networked Prototyping/Raw Data: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
(Blanked the page)
 
Line 1: Line 1:
        _______  _______            _______          ______  _________ _______              _________ ______  _______  _______
        (  ____ )(  ___  )|\    /|  (  ___  )|\    /|(  __  \ \__  __/(  ___  )    |\    /|\__  __/(  __  \ (  ____ \(  ___  )
        | (    )|| (  ) || )  ( |  | (  ) || )  ( || (  \  )  ) (  | (  ) |    | )  ( |  ) (  | (  \  )| (    \/| (  ) |
        | (____)|| (___) || | _ | |  | (___) || |  | || |  ) |  | |  | |  | |    | |  | |  | |  | |  ) || (__    | |  | |
        |    __)|  ___  || |( )| |  |  ___  || |  | || |  | |  | |  | |  | |    ( (  ) )  | |  | |  | ||  __)  | |  | |
        | (\ (  | (  ) || || || |  | (  ) || |  | || |  ) |  | |  | |  | |    \ \_/ /    | |  | |  ) || (      | |  | |
        | ) \ \__| )  ( || () () |  | )  ( || (___) || (__/  )___) (___| (___) |      \  /  ___) (___| (__/  )| (____/\| (___) |
        |/  \__/|/    \|(_______)  |/    \|(_______)(______/ \_______/(_______)      \_/  \_______/(______/ (_______/(_______)


<gallery>
File:image1.gif| TGA Output Gif 1
File:image2.gif| TGA Output Gif 2
File:image3.gif| TGA Output Gif 3
File:image4.gif| TGA Output Gif 4
File:image5.gif| TGA Output Gif 5
</gallery>
<source lang="python">
import struct, array, random, math
width = 1920
height = 1080
N = 1
redcount = 0
count = 0
for y in range(5): #25 frames a sec
datafile = open('images/image%d.tga' %(N,), 'wb')
header = struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 8, 0, 0, width, height, 32, 1 << 5)
datafile.write(header)
data = ''
screentime = ((width * height) / (random.randint(1,2)))
for x in xrange(width):
redcount = random.randint(0,255)
var = random.uniform(0,2)
for y in xrange (height):
r = redcount
g = 0
b = 0
a = 0
if count >= ((var * 90) * float(screentime)):
r = 0
g = redcount
if count >= ((var * 40) * float(screentime)):
g = 0
b = redcount
if count >= ((var * 80) * float(screentime)):
b = 0
a = redcount
if count >= ((var * 160) * float(screentime)):
count = 0
data += struct.pack('BBBB', b, g, r, a)
#print screentime
count = count + 1
print N
N = N + 1
datafile.write(data)
datafile.close()
</source>

Latest revision as of 09:26, 8 September 2016