### Working state as of last nite

master
Glen Whitney 3 years ago
parent
commit
9c375e54ac
2 changed files with 85 additions and 50 deletions
1. 95
firestar.py
2. 40
fivecolor.py

#### 95 firestar.py Unescape Escape View File

 `@ -1,6 +1,8 @@` @@ -1,6 +1,8 @@ `#!/usr/bin/python3` `from phue import Bridge` `import time` `import random` ``` ``` `b = Bridge('172.18.130.12')` `Nedges = 30;` `edgecode = [None] * Nedges;` `@ -24,11 +26,11 @@ def hueint(frac): return int((frac % 1)*lasthue)` @@ -24,11 +26,11 @@ 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]` ` [0,1/2) to [0,1/6) and [1/2,1) to [9/20,14/20)` ` '''` ` frac = frac % 1` ` if frac < 0.5: return hueint(frac/3);` ` else: return hueint((frac+1)/3);` ` else: return hueint((frac + 0.4)/2);` ` ` `def vivid(hue): return {'hue' : hue, 'bri' : fullbright, 'sat' : fullsat}` ``` ``` `@ -53,11 +55,11 @@ redred = (alltogether, [vivid(hueint(0))])` @@ -53,11 +55,11 @@ redred = (alltogether, [vivid(hueint(0))]) `# simpleshow.` ``` ``` `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)])` ` [(0,1,0), (1,40,40),` ` (2,1,10), (1,1,10), (2,1,10), (1,1,10), (2,1,10), (1,1,10), (2,1,10),` ` (3,60,40), (0,30,5)])` ``` ``` `interlude = ([thevoid], [(0,30,10)])` `interlude = ([thevoid], [(0,30,10),(0,30,10)])` ``` ``` `def runsimple(ss):` ` '''Takes one argument, a simple show; causes the simple show to be` `@ -68,45 +70,68 @@ def runsimple(ss):` @@ -68,45 +70,68 @@ def runsimple(ss): ` theset = settings[setting_index]` ` subs = theset[0]` ` cmds = theset[1]` ` nsubs = length(subs)` ` nsubs = len(subs)` ` for i in range(0,nsubs):` ` thiscmd = cmds[i].copy()` ` thiscmd['transitiontime'] = transition_to` ` b.set_light([edges[e].light_id for e in subs[i]], thiscmd)` ` time.sleep(hold_time/10)` ` time.sleep((transition_to + hold_time)/10)` ``` ``` `runsimple(intro)` `#runsimple(intro)` ``` ``` `# Tour of 5-colorings by Henry Segerman` `basehues = {'Red': 0, 'Orange': 5461, 'Yellow': 10923, 'Cyan': 32768,` ` 'Blue': 43691}` `# The most symmetric five-coloring of edges` `fivecs = [];` ``` ``` `fivehues = [basehues[c] for c in ['Red', 'Orange', 'Yellow', 'Cyan', 'Blue']]` `fivecs.append([[0,17, 12,22, 9,25], [3,11, 16,21, 8,26], [1,20, 10,15, 7,27],` ` [2,23, 13,18, 5,29], [4,14, 19,24, 6,28]]);` ``` ``` `fivecolors = [vivid(h) for h in fivehues]` `exec(open("fivecolor.py").read())` ``` ``` `fivecs = [];` `#runsimple(interlude)` `#runsimple(jmsshow1)` `#runsimple(interlude)` `#runsimple(jmsshow2)` ``` ``` `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]]` `# Let's identify the stars:` `stars = [[0,1,8,24,13], [17,20,26,19,18], [0,4,5,10,21], [17,14,29,15,16],` ` [1,2,6,12,16], [20,23,28,22,21], [2,3,9,15,19], [23,11,25,10,24],` ` [3,4,7,18,22], [11,14,27,13,12], [5,6,7,8,9], [29,28,27,26,25]]` ``` ``` `exec(open("fivecolor.py").read())` `starsettings = []` `for off in [0,2]:` ` for s in range(0,12):` ` starsettings.append(([stars[s]],` ` [{'hue': fshue((off+s)/4 + random.uniform(0,1/4)),` ` 'sat': random.randint(191,254),` ` 'bri': fullbright}]))` `starshow = (starsettings, [(n,10,30) for n in range(0,24)])` ``` ``` `#runsimple(interlude)` `#runsimple(starshow)` ``` ``` `# Tour of 5-colorings suggested by Henry Segerman implemented by Henry` `# Segerman and Glen Whitney, based on` `# http://www.weddslist.com/writing/icos/listc.html` `# The keys in basehues are Nick's color symbols,` `# even though they correspond to` `# Red, orangeY, Goldenrod, cyanoBlue, and darKblue` `# Map from Nick's vertex pairs to FireStar edge numbers:` `# ` ``` ``` `basehues = {'R': 0, 'Y': 5461, 'G': 10923, 'B': 32768, 'K': 43691}` ``` ``` `def vb(ltr): return vivid(basehues[ltr])` ``` ``` `fivecolors = [vb(c) for c in ['R', 'Y', 'G', 'B', 'K']]` ``` ``` `# Nick's coloring (NC) "0"` `fivetour = [(fivecs[0], fivecolors)]` `# Step NC "0" to NC "1"` `fivetour.append(([[3,21,26],[4,19,28]], [vb('K'),vb('Y')]))` `# Step NC "1" to NC "0"` `fivetour.append(([[3,21,26],[4,19,28]], [vb('Y'),vb('K')]))` ``` ``` `tour5show = (fivetour, [(0,30,20),(1,5,5),(2,5,5),(1,5,5),(2,5,5),(1,5,30)])` ``` ``` `runsimple(interlude)` `runsimple(jmsshow1)` `runsimple(interlude)` `runsimple(jmsshow2)` `runsimple(tour5show)`

#### 40 fivecolor.py Unescape Escape View File

 `@ -1,15 +1,17 @@` @@ -1,15 +1,17 @@ `### firestar show based on the most symmetric five-coloring` `### by John M. Sullivan` ``` ``` `sfive = fivecs[0]` ``` ``` `def somecolors(x, n=5, wh=False):` ` colors = []` ` for i in range(0,4):` ` for i in range(0,5):` ` if i < n:` ` colors.append(vivid(fshue(x+i/5)))` ` elif i == n and wh:` ` colors.append(white)` ` else:` ` colors.append(black)` ` colors.append(vivid(fshue(x+i/5)))` ` elif i == n and wh:` ` colors.append(white)` ` else:` ` colors.append(black)` ` return colors` ``` ``` `jmscolorings1 = [` `@ -23,16 +25,24 @@ jmscolorings1 = [` @@ -23,16 +25,24 @@ jmscolorings1 = [ ``` ``` `jmssettings1 = [(fivecs[0], col) for col in jmscolorings1]` ``` ``` `jmssettings1 = [thevoid]` `for i in range (0,5):` ` jmssettings1.append(([sfive[i]], [white]))` ` jmssettings1.append(([sfive[i]], [black]))` ` jmssettings1.append(([sfive[i]], [vivid(fshue(i/5))]))` ``` ``` `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)]` ` [(0,1,5),` ` (1,1,5),(2,1,5),(1,1,5),(3,1,30),` ` (4,1,5),(5,1,5),(4,1,5),(6,1,30),` ` (7,1,5),(8,1,5),(7,1,5),(9,1,30),` ` (10,1,5),(11,1,5),(10,1,5),(12,1,30),` ` (13,1,5),(14,1,5),(13,2,8),(15,2,100)])` ``` ``` `Nframes = 60` ``` ``` `jmscolorings2 = [somecolors(x/Nframes) for x in range(0,Nframes)]` `jmssettings2 = [(fivecs[0], col) for col in jmscolorings2]` `jmstimings2 = [(n,2,0) for n in range(0,119)]` `jmstimings2 = [(n,2,0) for n in range(0,Nframes)]` ``` ``` `jmsshow2 = (jmssettings2, jmstimings2)`