1 class WarmPlasma extends SCPattern {
3 private float satu = 100;
4 private float speed = 1;
5 BasicParameter saturationParameter = new BasicParameter("SATU", 1.0);
6 BasicParameter speedParameter = new BasicParameter("SPEED", 0.1);
8 public WarmPlasma(GLucose glucose) {
10 addParameter(saturationParameter);
11 addParameter(speedParameter);
13 public void onParameterChanged(LXParameter parameter) {
14 if (parameter == saturationParameter) {
15 satu = 100*parameter.getValuef();
16 } else if (parameter == speedParameter) {
17 speed = 10*parameter.getValuef();
21 public void run(int deltaMs) {
22 for (Point p : model.points) {
23 float hv = sin(dist(p.fx + pos, p.fy, 128.0, 128.0) / 8.0)
24 + sin(dist(p.fx, p.fy, 64.0, 64.0) / 8.0)
25 + sin(dist(p.fx, p.fy + pos / 7, 192.0, 64.0) / 7.0)
26 + sin(dist(p.fx, p.fz + pos, 192.0, 100.0) / 8.0);
28 colors[p.index] = color((hv+2)*25, satu, bv);
31 if (pos >= MAX_INT-1) pos=0;
35 // This is very much a work in progress. Trying to get a flame effect.
36 class FireTest extends SCPattern {
37 private float[][] intensity;
38 private float hotspot;
39 private float decay = 0.3;
42 BasicParameter decayParameter = new BasicParameter("DECAY", 0.3);
44 public FireTest(GLucose glucose) {
49 intensity = new float[xm][ym];
50 addParameter(decayParameter);
52 public void onParameterChanged(LXParameter parameter) {
53 if (parameter == decayParameter) {
54 decay = parameter.getValuef();
57 private color flameColor(float level) {
58 if (level<=0) return color(0,0,0);
59 float br=min(100,sqrt(level)*15);
60 return color(level/1.7,100,br);
62 public void run(int deltaMs) {
63 for (int x=10;x<xm-10;x++) {
64 if (x%50>45 || x%50<5) {
65 intensity[x][ym-1] = random(30,100);
67 intensity[x][ym-1] = random(0,50);
70 for (int x=1;x<xm-1;x++) {
71 for (int y=0;y<ym-1;y++) {
72 intensity[x][y] = (intensity[x-1][y+1]+intensity[x][y+1]+intensity[x+1][y+1])/3-decay;
76 for (Point p : model.points) {
77 int x = (int(p.fx)+int(p.fz))%xm;
78 int y = min(ym-int(p.fy),ym-1);
79 colors[p.index] = flameColor(intensity[x][y]);