Browse Source

2to3

master
Fr3deric 7 years ago
parent
commit
8311e3fc11
  1. 2
      fire,py
  2. 10
      fire.py

2
fire,py

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
#!/usr/bin/python

10
fire.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import colorsys
import random
@ -11,11 +11,11 @@ import blup.animation @@ -11,11 +11,11 @@ import blup.animation
# http://quiteuseful.co.uk/post/96424751/beautiful-algorithms-1-fire-part-2
dim = blup.frame.FrameDimension(18,8,16,3)
dim = blup.frame.FrameDimension(22,16,256,3)
anim = blup.animation.Animation(dim)
def getRandomColor(maxval):
return mmeap(lambda x: int(round(x*maxval)), colorsys.hsv_to_rgb(random.random() % 0.16666666, 1, 1))
return list(map(lambda x: int(round(x*maxval)), colorsys.hsv_to_rgb(random.random() % 0.16666666, 1, 1)))
def colorAvg(colors):
r = 0
@ -26,13 +26,13 @@ def colorAvg(colors): @@ -26,13 +26,13 @@ def colorAvg(colors):
g += c[1]
b += c[2]
avg = (r,g,b)
avg = map(lambda x: int(round(x / (len(colors) * 1.0))), avg)
avg = list(map(lambda x: int(round(x / (len(colors) * 1.0))), avg))
return avg
for i in range(100):
randRow = [ getRandomColor(dim.depth - 1) for i in range(dim.width) ]
print randRow
print(randRow)
f = blup.animation.AnimationFrame(dim, 60)

Loading…
Cancel
Save