Add 5-coloring shows by John Sullivan and start on Henry Segerman's
This commit is contained in:
parent
10076aa667
commit
8817603fb1
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,7 @@
|
||||
# ---> Python
|
||||
# emacs
|
||||
*~
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
@ -3,3 +3,5 @@
|
||||
code to drive a light show on the edges of a small stellated dodecahedron, each with a Phillips Hue lightstrip embedded in it.
|
||||
|
||||
This project depends on the phue package (https://github.com/studioimaginaire/phue) which you should be able to install via `sudo pip3 install phue`.
|
||||
|
||||
Copyright 2019 by Glen Whitney with contributions by others as noted in the code.
|
||||
|
67
firestar.py
67
firestar.py
@ -43,7 +43,25 @@ edgecode[29] = 'XX';
|
||||
|
||||
edges = [ b[code] for code in edgecode ]
|
||||
|
||||
def hueint(frac): return int(frac*65535)
|
||||
lasthue = 65535
|
||||
fullbright = 254
|
||||
fullsat = 254
|
||||
|
||||
# some color preliminaries
|
||||
white = {'hue' : 0, 'bri' : fullbright, 'sat' : 0}
|
||||
black = {'bri' : 0, 'sat' : 0}
|
||||
|
||||
def hueint(frac): return int((frac % 1)*lasthue)
|
||||
|
||||
def fshue(frac):
|
||||
'''Returns a hue number based on the fractional part of frac, warping
|
||||
[0,1/2) to [0,1/6) and [1/2,1) to [1/2,2/3]
|
||||
'''
|
||||
frac = frac % 1
|
||||
if frac < 0.5: return hueint(frac/3);
|
||||
else: return hueint((frac+1)/3);
|
||||
|
||||
def vivid(hue): return {'hue' : hue, 'bri' : fullbright, 'sat' : fullsat}
|
||||
|
||||
# A "setting" is a pair of a list of N lists of edges, and a list of N dicts
|
||||
# understandable by Bridge.set_light,
|
||||
@ -53,10 +71,10 @@ def hueint(frac): return int(frac*65535)
|
||||
# in any list will be left alone.
|
||||
|
||||
alltogether = [range(0,Nedges)];
|
||||
thevoid = (alltogether, ['bri' : 0])
|
||||
deepblue = (alltogether, [{'hue' : hueint(2/3), 'bri' : 254, 'sat' : 254}])
|
||||
yelorng = (alltogether, [{'hue' : hueint(1/6), 'bri' : 254, 'sat' : 254}])
|
||||
redred = (alltogether, [{'hue' : 0, 'bri' : 254, 'sat' : 254}])
|
||||
thevoid = (alltogether, [black])
|
||||
deepblue = (alltogether, [vivid(hueint(2/3))])
|
||||
yelorng = (alltogether, [vivid(hueint(1/6))])
|
||||
redred = (alltogether, [vivid(hueint(0))])
|
||||
|
||||
# A "simpleshow" is a pair of a list of settings, and a list of triples of
|
||||
# integers: (setting_index, transition_to, hold_time)
|
||||
@ -68,8 +86,9 @@ redred = (alltogether, [{'hue' : 0, 'bri' : 254, 'sat' : 254}])
|
||||
intro = ([thevoid, deepblue, yelorng, redred],
|
||||
[(0,1,0), (1,30,20),
|
||||
(2,1,3), (1,1,3), (2,1,3), (1,1,3), (2,1,3), (1,1,3), (2,1,0),
|
||||
(3,50,20), (0,30,5)]
|
||||
)
|
||||
(3,50,20), (0,30,5)])
|
||||
|
||||
interlude = ([thevoid], [(0,30,10)])
|
||||
|
||||
def runsimple(ss):
|
||||
'''Takes one argument, a simple show; causes the simple show to be
|
||||
@ -88,3 +107,37 @@ def runsimple(ss):
|
||||
time.sleep(hold_time/10)
|
||||
|
||||
runsimple(intro)
|
||||
|
||||
# Tour of 5-colorings by Henry Segerman
|
||||
basehues = {'Red': 0, 'Orange': 5461, 'Yellow': 10923, 'Cyan': 32768,
|
||||
'Blue': 43691}
|
||||
|
||||
fivehues = [basehues[c] for c in ['Red', 'Orange', 'Yellow', 'Cyan', 'Blue']]
|
||||
|
||||
fivecolors = [vivid(h) for h in fivehues]
|
||||
|
||||
fivecs = [];
|
||||
|
||||
fivecs.append([[0,22,9,12,25,17], [27,20,10,7,1,15], [26,11,21,8,3,16],
|
||||
[29,23,13,18,5,2], [28,24,4,6,14,19]]);
|
||||
|
||||
#fivecs.append(([[0,22,9,12,25,17], [27,20,15,24,6,4], [26,11,21,8,3,16],
|
||||
# [29,23,13,18,5,2], [28,14,19,10,1,7]], fivecolors));
|
||||
#fivecs.append(([[12,25,17,8,3,21], [27,20,15,24,6,4], [26,11,16,0,9,22],
|
||||
# [29,23,13,18,5,2], [28,14,19,10,1,7]], fivecolors));
|
||||
#fivecs.append(([[12,17,8,3,28,10], [27,20,15,24,6,4], [26,11,16,0,9,22],
|
||||
# [29,23,13,18,5,2], [14,19,1,7,25,21]], fivecolors));
|
||||
#fivecs.append(([[12,17,8,3,28,10], [27,20,24,4,16,9], [26,11,0,22, ,15,6],[29,23,13,18,5,2],[14,19, 1,7, 25,21]]
|
||||
#
|
||||
#"5"
|
||||
#[[17, 3, 28, 0,6,11],[27,20, 24,4, 16,9],[26, 22, 15, 8,12,10 ],[29,23,13,18,5,#2],[14,19, 1,7, 25,21]]
|
||||
#
|
||||
#"6"
|
||||
#[[17, 3, 28, 0,6,11],[27, 24, 16, 7,19,21],[26, 22, 15, 8,12,10 ],[29,23,13,18,5,2],[14, 1, 25, 4,9,20]]
|
||||
|
||||
exec(open("fivecolor.py").read())
|
||||
|
||||
runsimple(interlude)
|
||||
runsimple(jmsshow1)
|
||||
runsimple(interlude)
|
||||
runsimple(jmsshow2)
|
||||
|
38
fivecolor.py
Normal file
38
fivecolor.py
Normal file
@ -0,0 +1,38 @@
|
||||
### firestar show based on the most symmetric five-coloring
|
||||
### by John M. Sullivan
|
||||
|
||||
def somecolors(x, n=5, wh=False):
|
||||
colors = []
|
||||
for i in range(0,4):
|
||||
if i < n:
|
||||
colors.append(vivid(fshue(x+i/5)))
|
||||
elif i == n and wh:
|
||||
colors.append(white)
|
||||
else:
|
||||
colors.append(black)
|
||||
return colors
|
||||
|
||||
jmscolorings1 = [
|
||||
somecolors(0,0), somecolors(0,0,True),
|
||||
somecolors(0,1), somecolors(0,1,True),
|
||||
somecolors(0,2), somecolors(0,2,True),
|
||||
somecolors(0,3), somecolors(0,3,True),
|
||||
somecolors(0,4), somecolors(0,4,True),
|
||||
somecolors(0)
|
||||
]
|
||||
|
||||
jmssettings1 = [(fivecs[0], col) for col in jmscolorings1]
|
||||
|
||||
jmsshow1 = (jmssettings1,
|
||||
[(0,1,2),
|
||||
(1,1,2),(0,1,2),(1,1,2),(2,1,30),
|
||||
(3,1,2),(2,1,2),(3,1,2),(4,1,30),
|
||||
(5,1,2),(4,1,2),(5,1,2),(6,1,30),
|
||||
(7,1,2),(6,1,2),(7,1,2),(8,1,30),
|
||||
(9,1,2),(8,1,2),(9,1,2),(10,1,90)])
|
||||
|
||||
jmscolorings2 = [somecolors(x/120) for x in range(0,119)]
|
||||
jmssettings2 = [(fivecs[0], col) for col in jmscolorings2]
|
||||
jmstimings2 = [(n,2,0) for n in range(0,119)]
|
||||
|
||||
jmsshow2 = (jmssettings2, jmstimings2)
|
Loading…
Reference in New Issue
Block a user