From: Toby Segaran Date: Wed, 7 Aug 2013 23:03:47 +0000 (-0700) Subject: Added TobySegaran.pde with a couple of new patterns X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4ad0649d4c40d15ad121611ce2afa1c33d870df7;p=SugarCubes.git Added TobySegaran.pde with a couple of new patterns --- diff --git a/SugarCubes.pde b/SugarCubes.pde index 5504001..744624e 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -25,6 +25,8 @@ LXPattern[] patterns(GLucose glucose) { return new LXPattern[] { + new WarmPlasma(glucose), + new FireTest(glucose), new ShiftingPlane(glucose), new AskewPlanes(glucose), new Swarm(glucose), 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