-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy paths-color4-faster.py
executable file
·57 lines (46 loc) · 1.22 KB
/
s-color4-faster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import acabsl
from acabsl import send
from acabsl import update
import colorsys
import random
import time
import math
tick = 1.65 / 10
def setcol(col, r, g, b, time):
for i in range(0,6):
send(col,i,r,g,b,time);
h = 0
col = 0
midcol = acabsl.WALLSIZEX/2
midrow = acabsl.WALLSIZEY/2
maxdist = 0
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)
if dist > maxdist:
maxdist = dist
hoffset = 0
update()
while 1:
midcol = min(acabsl.WALLSIZEX-2,max(1, midcol + random.gauss(0,0.1)))
midrow = min(acabsl.WALLSIZEY-2,max(1, midrow + random.gauss(0,0.1)))
#hoffset += random.gauss(0.01,0.02)
hoffset += 0.03
hoffset = hoffset % 1.
#t = time.time()
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)/maxdist
h = (math.atan2(dc, dr) + math.pi/2)/math.pi/2
h = (h+hoffset) % 1.
r,g,b = colorsys.hsv_to_rgb(h, dist, 1)
send(int(col), int(row), r*255, g*255, b*255, tick*2)
#print time.time()-t
update()
time.sleep(tick)