Commit | Line | Data |
---|---|---|
0208d845 AB |
1 | |
2 | class TelevisionStatic extends SCPattern { | |
3 | BasicParameter brightParameter = new BasicParameter("BRIGHT", 1.0); | |
4 | BasicParameter saturationParameter = new BasicParameter("SAT", 1.0); | |
5 | BasicParameter hueParameter = new BasicParameter("HUE", 1.0); | |
6 | SinLFO direction = new SinLFO(0, 10, 3000); | |
7 | ||
dde75983 MS |
8 | public TelevisionStatic(LX lx) { |
9 | super(lx); | |
0208d845 AB |
10 | addModulator(direction).trigger(); |
11 | addParameter(brightParameter); | |
12 | addParameter(saturationParameter); | |
13 | addParameter(hueParameter); | |
14 | } | |
15 | ||
34327c96 | 16 | void run(double deltaMs) { |
0208d845 | 17 | boolean d = direction.getValuef() > 5.0; |
2bb56822 | 18 | for (LXPoint p : model.points) { |
a41f334c | 19 | colors[p.index] = lx.hsb((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100)); |
0208d845 AB |
20 | } |
21 | } | |
22 | } | |
23 | ||
24 | class AbstractPainting extends SCPattern { | |
25 | ||
26 | PImage img; | |
27 | ||
28 | SinLFO colorMod = new SinLFO(0, 360, 5000); | |
29 | SinLFO brightMod = new SinLFO(0, model.zMax, 2000); | |
30 | ||
dde75983 MS |
31 | public AbstractPainting(LX lx) { |
32 | super(lx); | |
0208d845 AB |
33 | addModulator(colorMod).trigger(); |
34 | addModulator(brightMod).trigger(); | |
35 | ||
36 | img = loadImage("abstract.jpg"); | |
37 | img.loadPixels(); | |
38 | } | |
39 | ||
34327c96 | 40 | void run(double deltaMs) { |
2bb56822 | 41 | for (LXPoint p : model.points) { |
0208d845 | 42 | color c = img.get((int)((p.x / model.xMax) * img.width), img.height - (int)((p.y / model.yMax) * img.height)); |
a41f334c | 43 | colors[p.index] = lx.hsb(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.z - brightMod.getValuef())/p.z)); |
0208d845 AB |
44 | } |
45 | } | |
46 | } | |
47 | ||
48 | class Spirality extends SCPattern { | |
49 | final BasicParameter r = new BasicParameter("RADIUS", 0.5); | |
50 | ||
51 | float angle = 0; | |
52 | float rad = 0; | |
53 | int direction = 1; | |
54 | ||
dde75983 MS |
55 | Spirality(LX lx) { |
56 | super(lx); | |
0208d845 | 57 | addParameter(r); |
2bb56822 | 58 | for (LXPoint p : model.points) { |
a41f334c | 59 | colors[p.index] = lx.hsb(0, 0, 0); |
0208d845 AB |
60 | } |
61 | } | |
62 | ||
34327c96 | 63 | public void run(double deltaMs) { |
0208d845 AB |
64 | angle += deltaMs * 0.007; |
65 | rad += deltaMs * .025 * direction; | |
66 | float x = model.xMax / 2 + cos(angle) * rad; | |
67 | float y = model.yMax / 2 + sin(angle) * rad; | |
2bb56822 | 68 | for (LXPoint p : model.points) { |
190d91c2 | 69 | float b = dist(x,y,p.x,p.y); |
0208d845 AB |
70 | if (b < 90) { |
71 | colors[p.index] = blendColor( | |
72 | colors[p.index], | |
a41f334c | 73 | lx.hsb(lx.getBaseHuef() + 25, 10, map(b, 0, 10, 100, 0)), |
0208d845 AB |
74 | ADD); |
75 | } else { | |
76 | colors[p.index] = blendColor( | |
77 | colors[p.index], | |
a41f334c | 78 | lx.hsb(25, 10, map(b, 0, 10, 0, 15)), |
0208d845 AB |
79 | SUBTRACT); |
80 | } | |
81 | } | |
82 | if (rad > model.xMax / 2 || rad <= .001) { | |
83 | direction *= -1; | |
84 | } | |
85 | } | |
86 | } | |
87 | ||
88 | ||
89 | ||
90 |