X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TobySegaran.pde;fp=TobySegaran.pde;h=6b72d30349e09522d082803b2416ce544f7218ff;hb=4ad0649d4c40d15ad121611ce2afa1c33d870df7;hp=0000000000000000000000000000000000000000;hpb=9299ed7cf2cd9fb180f95d2cd22f63afa1863fe0;p=SugarCubes.git diff --git a/TobySegaran.pde b/TobySegaran.pde new file mode 100644 index 0000000..6b72d30 --- /dev/null +++ b/TobySegaran.pde @@ -0,0 +1,81 @@ +class WarmPlasma extends SCPattern { + private int pos = 0; + private float satu = 100; + private float speed = 1; + BasicParameter saturationParameter = new BasicParameter("SATU", 1.0); + BasicParameter speedParameter = new BasicParameter("SPEED", 0.1); + + public WarmPlasma(GLucose glucose) { + super(glucose); + addParameter(saturationParameter); + addParameter(speedParameter); + } + public void onParameterChanged(LXParameter parameter) { + if (parameter == saturationParameter) { + satu = 100*parameter.getValuef(); + } else if (parameter == speedParameter) { + speed = 10*parameter.getValuef(); + } + } + + public void run(int deltaMs) { + for (Point p : model.points) { + float hv = sin(dist(p.fx + pos, p.fy, 128.0, 128.0) / 8.0) + + sin(dist(p.fx, p.fy, 64.0, 64.0) / 8.0) + + sin(dist(p.fx, p.fy + pos / 7, 192.0, 64.0) / 7.0) + + sin(dist(p.fx, p.fz + pos, 192.0, 100.0) / 8.0); + float bv = 100; + colors[p.index] = color((hv+2)*25, satu, bv); + } + pos+=speed; + if (pos >= MAX_INT-1) pos=0; + } +} + +class FireTest extends SCPattern { + private float[][] intensity; + private float hotspot; + private float decay = 0.3; + private int xm; + private int ym; + BasicParameter decayParameter = new BasicParameter("DECAY", 0.3); + + public FireTest(GLucose glucose) { + super(glucose); + xm = int(model.xMax); + ym = int(model.yMax); + + intensity = new float[xm][ym]; + addParameter(decayParameter); + } + public void onParameterChanged(LXParameter parameter) { + if (parameter == decayParameter) { + decay = parameter.getValuef(); + } + } + private color flameColor(float level) { + if (level<=0) return color(0,0,0); + float br=min(100,sqrt(level)*15); + return color(level/1.7,100,br); + } + public void run(int deltaMs) { + for (int x=10;x45 || x%50<5) { + intensity[x][ym-1] = random(30,100); + } else { + intensity[x][ym-1] = random(0,50); + } + } + for (int x=1;x