Changeset - a322fba0035c
[Not reviewed]
default
0 1 1
Drew Perttula - 6 years ago 2019-06-09 18:31:47
drewp@bigasterisk.com
tintable cyc effect
Ignore-this: 61408125389e6146f5835d56a26df07a
2 files changed with 28 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval.py
Show inline comments
 
@@ -367,48 +367,70 @@ def effect_Strobe(effectSettings, streng
 
    f = (((songTime + offset) * rate) % 1.0)
 
    c = (f < duty) * strength
 
    col = rgb_to_hex([int(c * 255), int(c * 255), int(c * 255)])
 
    return {(L9['device/colorStrip'], L9['color']): Literal(col)}
 

	
 

	
 
def effect_lightning(effectSettings, strength, songTime, noteTime):
 
    devs = [
 
        L9['device/veryLow1'], L9['device/veryLow2'], L9['device/veryLow3'],
 
        L9['device/veryLow4'], L9['device/veryLow5'], L9['device/backlight1'],
 
        L9['device/backlight2'], L9['device/backlight3'],
 
        L9['device/backlight4'], L9['device/backlight5'], L9['device/down2'],
 
        L9['device/down3'], L9['device/down4'], L9['device/hexLow3'],
 
        L9['device/hexLow5'], L9['device/postL1'], L9['device/postR1']
 
    ]
 
    out = {}
 
    col = rgb_to_hex([int(255 * strength)] * 3)
 
    for i, dev in enumerate(devs):
 
        n = noise(songTime * 8 + i * 6.543)
 
        if n > .4:
 
            out[(dev, L9['color'])] = col
 
    return out
 

	
 

	
 
def sample(img, x, y, repeat=False):
 
    if 0 <= x < img.width:
 
        return img.getpixel((x, y))
 
    elif not repeat:
 
        return (0, 0, 0)
 
    else:
 
        return img.getpixel((x % img.width, y))
 

	
 

	
 
def effect_image(effectSettings, strength, songTime, noteTime):
 
    out = {}
 
    imgPath = f'cur/anim/{effectSettings[L9["image"]]}'
 
    t_offset = effectSettings.get(L9['tOffset'], 0)
 
    pxPerSec = effectSettings.get(L9['pxPerSec'], 30)
 
    img = Image.open(imgPath)
 
    x = (noteTime * pxPerSec)
 

	
 
    scl = effectSettings.get(L9['strength'], 1)
 
    for dev, y in [(L9['theater/skyline/device/strip1'], 0),
 
                   (L9['theater/skyline/device/strip2'], 1),
 
                   (L9['theater/skyline/device/strip3'], 2)]:
 
        color = sample(img, x, y, effectSettings.get(L9['repeat'], False))
 
        out[(dev, L9['color'])] = scale(rgb_to_hex(color), scl)
 
    return out
 

	
 
def effect_cyc(effectSettings, strength, songTime, noteTime):
 
    colorScale = effectSettings.get(L9['colorScale'], '#ffffff')
 
    r, g, b = map(lambda x: x / 255, hex_to_rgb(colorScale))
 

	
 
    out ={
 
        (L9['theater/skyline/device/cycRed1'], L9['brightness']): r,
 
        (L9['theater/skyline/device/cycRed2'], L9['brightness']): r,
 
        (L9['theater/skyline/device/cycRed3'], L9['brightness']): r,
 
        (L9['theater/skyline/device/cycRed4'], L9['brightness']): r,
 
        (L9['theater/skyline/device/cycGreen1'], L9['brightness']): g,
 
        (L9['theater/skyline/device/cycGreen2'], L9['brightness']): g,
 
        (L9['theater/skyline/device/cycGreen3'], L9['brightness']): g,
 
        (L9['theater/skyline/device/cycGreen4'], L9['brightness']): g,
 
        (L9['theater/skyline/device/cycBlue1'], L9['brightness']): b,
 
        (L9['theater/skyline/device/cycBlue2'], L9['brightness']): b,
 
        (L9['theater/skyline/device/cycBlue3'], L9['brightness']): b,
 
        (L9['theater/skyline/device/cycBlue4'], L9['brightness']): b,
 
         
 
        }
 

	
 
    return out
show/dance2019/effects.n3
Show inline comments
 
new file 100644
 
@prefix : <http://light9.bigasterisk.com/> .
 
@prefix e: <http://light9.bigasterisk.com/effect/> .
 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 

	
 
e:cyc a :Effect ; rdfs:label "cyc".
0 comments (0 inline, 0 general)