Changeset - 97a7c71b952a
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 6 years ago 2019-06-10 01:39:26
drewp@bigasterisk.com
1 file changed with 15 insertions and 9 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval.py
Show inline comments
 
@@ -11,7 +11,6 @@ from typing import Dict, Tuple, Any
 
from PIL import Image
 
import random
 

	
 

	
 
SKY = Namespace('http://light9.bigasterisk.com/theater/skyline/device/')
 

	
 
random.seed(0)
 
@@ -64,6 +63,7 @@ def _8bit(f):
 
        raise TypeError(repr(f))
 
    return clamp255(int(f * 255))
 

	
 

	
 
class EffectEval(object):
 
    """
 
    runs one effect's code to turn effect attr settings into output
 
@@ -421,10 +421,10 @@ def effect_image(effectSettings, strengt
 
    img = Image.open(imgPath)
 
    x = (noteTime * pxPerSec)
 
    
 
    colorScale = hex_to_rgb(effectSettings.get(L9['colorScale'],
 
                                               '#ffffff'))
 
    colorScale = hex_to_rgb(effectSettings.get(L9['colorScale'], '#ffffff'))
 

	
 
    for dev, y in [(SKY['strip1'], 0),
 
    for dev, y in [
 
        (SKY['strip1'], 0),
 
                   (SKY['strip2'], 1),
 
                   (SKY['strip3'], 2),
 
                   (SKY['par3'], 3), # dl
 
@@ -455,6 +455,7 @@ def effect_image(effectSettings, strengt
 
            out[(dev, L9['color'])] = rgb_to_hex(map(_8bit, color))
 
    return out
 

	
 

	
 
def effect_cyc(effectSettings, strength, songTime, noteTime):
 
    colorScale = effectSettings.get(L9['colorScale'], '#ffffff')
 
    r, g, b = map(lambda x: strength * x / 255, hex_to_rgb(colorScale))
 
@@ -472,11 +473,11 @@ def effect_cyc(effectSettings, strength,
 
        (SKY['cycBlue2'], L9['brightness']): b,
 
        (SKY['cycBlue3'], L9['brightness']): b,
 
        (SKY['cycBlue4'], L9['brightness']): b,
 
         
 
        }
 

	
 
    return out
 

	
 

	
 
cycChase1_members = [
 
       SKY['cycRed1'], 
 
       SKY['cycRed2'], 
 
@@ -494,6 +495,7 @@ cycChase1_members = [
 
cycChase1_members = cycChase1_members * 20
 
random.shuffle(cycChase1_members)
 

	
 

	
 
def effect_cycChase1(effectSettings, strength, songTime, noteTime):
 
    colorScale = effectSettings.get(L9['colorScale'], '#ffffff')
 
    r, g, b = map(lambda x: x / 255, hex_to_rgb(colorScale))
 
@@ -518,16 +520,20 @@ def effect_cycChase1(effectSettings, str
 

	
 

	
 
def effect_parNoise(effectSettings, strength, songTime, noteTime):
 
    
 
    colorScale = effectSettings.get(L9['colorScale'], '#ffffff')
 
    r, g, b = map(lambda x: x / 255, hex_to_rgb(colorScale))
 
    out = {}
 
    speed = 10
 
    gamma = .6
 
    for dev in [SKY['strip1'], SKY['strip2'], SKY['strip3']]:
 
        out[(dev, L9['color'])] = scale(rgb_to_hex(
 
        out[(dev, L9['color'])] = scale(
 
            rgb_to_hex(
 
            (_8bit(r * math.pow(max(.01, noise(speed * songTime)), gamma)),
 
             _8bit(g * math.pow(max(.01, noise(speed * songTime + 10)), gamma)),
 
             _8bit(b * math.pow(max(.01, noise(speed * songTime + 20)), gamma)))), strength)
 
                 _8bit(g *
 
                       math.pow(max(.01, noise(speed * songTime + 10)), gamma)),
 
                 _8bit(
 
                     b *
 
                     math.pow(max(.01, noise(speed * songTime + 20)), gamma)))),
 
            strength)
 

	
 
    return out
0 comments (0 inline, 0 general)