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