You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB

7 years ago
#!/usr/bin/env python3
8 years ago
import colorsys
import random
import blup.frame
import blup.output
import blup.animation
# thanks to
# http://quiteuseful.co.uk/post/96424751/beautiful-algorithms-1-fire-part-2
7 years ago
dim = blup.frame.FrameDimension(22,16,256,3)
8 years ago
anim = blup.animation.Animation(dim)
def getRandomColor(maxval):
7 years ago
return list(map(lambda x: int(round(x*maxval)), colorsys.hsv_to_rgb(random.random() % 0.16666666, 1, 1)))
8 years ago
def colorAvg(colors):
r = 0
g = 0
b = 0
for c in colors:
r += c[0]
g += c[1]
b += c[2]
avg = (r,g,b)
7 years ago
avg = list(map(lambda x: int(round(x / (len(colors) * 1.0))), avg))
8 years ago
return avg
for i in range(100):
randRow = [ getRandomColor(dim.depth - 1) for i in range(dim.width) ]
7 years ago
print(randRow)
8 years ago
f = blup.animation.AnimationFrame(dim, 60)
for y in range(dim.height - 1, -1, -1):
for x in range(dim.width):
colors = []
if x >=1 :
colors.append(f.getPixel(x-1,y))
if x < dim.width - 1:
pass
colors.append(f.getPixel(x+1,y))
if y < dim.height - 1:
colors.append(f.getPixel(x, y+1))
else:
#colors.append(randRow[y])
colors.append(getRandomColor(dim.depth - 1))
#colors = [randRow[x]]
c = colorAvg(colors)
f.setPixel(x, y, c)
anim.addFrame(f)
#out = blup.output.getOutput('e3blp:bbunt:4242')
out = blup.output.getOutput('colorfulshell')
player = blup.animation.AnimationPlayer()
player.play(anim, out)