def plasma(): #led = LEDStripe() #led = Stripesim() led = Stripecache('oplasma3.a') x = np.linspace(0, 1, 240) t = 0 for i in range(100000): t += 0.1 yr = np.sin(2*np.pi*1*(1.3+np.sin(0.15*t))*x - 0.32*t) + \ np.sin(2*np.pi*3.32*(1.3-np.sin(0.18*t))*x + 0.76*t) + \ np.cos(2*np.pi*0.65*(1.3+np.sin(0.05*t))*x + 0.23*t) yr = (1.0 + yr) / 4.0 yr = np.maximum(np.minimum(yr, 1.0), 0.0) yg = np.sin(2*np.pi*1.43*(1.3-np.sin(0.21*t))*x + 0.12*t) + \ np.sin(2*np.pi*2.78*(1.3+np.sin(0.15*t))*x - 0.43*t) + \ np.cos(2*np.pi*0.23*(1.3-np.sin(0.05*t))*x + 0.33*t) yg = (1.0 + yg) / 4.0 yg = np.maximum(np.minimum(yg, 1.0), 0.0) yb = np.sin(2*np.pi*0.32*(1.3-np.sin(0.04*t))*x - 0.07*t) + \ np.sin(2*np.pi*0.87*(1.3+np.sin(0.2*t))*x + 0.12*t) + \ np.cos(2*np.pi*1.54*(1.3+np.sin(0.12*t))*x - 0.19*t) yb = (yb - 2.0) / 12.0 yb = np.maximum(np.minimum(yb, 1.0), 0.0) comb = np.array([yg, yr, yb]).transpose().flatten() led.write(comb)
class Burst(): def __init__(self): #self.led = Stripesim(size = 240) self.led = Stripecache('burst.a') def run(self): self.collide() self.explode() self.fadeout() def collide(self): for pos in range(120): out = np.zeros((240, 3)) out[pos, 1] = 1. out[239 - pos, 1] = 1. self.led.write(out.flatten()) def explode(self): coef = np.concatenate( (np.linspace(-np.pi / 2, 0, 120), np.linspace(0, np.pi / 2, 120))) for factor in np.logspace(-3, 0.6, 60)[::-1]: out = np.zeros((240, 3)) out[:, 0] = capcos(factor / 2 * coef) out[:, 1] = capcos(factor / 5 * coef) out[:, 2] = capcos(factor * coef) self.led.write(np.maximum(0.0, out.flatten())) def fadeout(self): out = np.ones((240, 3)) fade_b = 0.9 - np.random.rand(240) * 0.1 fade_g = 0.97 - np.random.rand(240) * 0.04 fade_r = 0.99 - np.random.rand(240) * 0.02 for i in range(250): out[:, 0] = out[:, 0] * fade_g out[:, 1] = out[:, 1] * fade_r out[:, 2] = out[:, 2] * fade_b self.led.write(out.flatten())
class Burst(): def __init__(self): #self.led = Stripesim(size = 240) self.led = Stripecache('burst.a') def run(self): self.collide() self.explode() self.fadeout() def collide(self): for pos in range(120): out = np.zeros((240, 3)) out[pos, 1] = 1. out[239-pos, 1] = 1. self.led.write(out.flatten()) def explode(self): coef = np.concatenate((np.linspace(-np.pi/2, 0, 120), np.linspace(0, np.pi/2, 120))) for factor in np.logspace(-3, 0.6, 60)[::-1]: out = np.zeros((240, 3)) out[:, 0] = capcos(factor/2 * coef) out[:, 1] = capcos(factor/5 * coef) out[:, 2] = capcos(factor * coef) self.led.write(np.maximum(0.0, out.flatten())) def fadeout(self): out = np.ones((240, 3)) fade_b = 0.9 - np.random.rand(240) * 0.1 fade_g = 0.97 - np.random.rand(240) * 0.04 fade_r = 0.99 - np.random.rand(240) * 0.02 for i in range(250): out[:, 0] = out[:, 0] * fade_g out[:, 1] = out[:, 1] * fade_r out[:, 2] = out[:, 2] * fade_b self.led.write(out.flatten())
def __init__(self): #self.led = Stripesim(size = 240) self.led = Stripecache('burst.a')