From: jackie Date: Sat, 23 Nov 2013 07:54:10 +0000 (-0800) Subject: Squashed commit of the following: X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=37ab5878ac35aff7c880c7fb47ed38e7b742764d;p=SugarCubes.git Squashed commit of the following: commit b3075ab07700df6b0ba8c972eaed3288c4dfa16d Author: jackie Date: Fri Nov 22 23:47:30 2013 -0800 rename to JackieSquares commit a5babd41b92abb12dd0f5d7f9847d4e74fe929b5 Author: jackie Date: Fri Nov 22 23:43:24 2013 -0800 looking good commit 58b6403fe84e8e26bc64bd937760674de5e2ad04 Author: jackie Date: Fri Nov 22 23:40:33 2013 -0800 adding variance commit 18573c7aca7e4e4b50ca7b9d7e1162658462ba6f Author: jackie Date: Fri Nov 22 23:30:26 2013 -0800 more time in stacks commit 4c9f98e3687054b151b247bb1d52358d7009a3ed Author: jackie Date: Fri Nov 22 23:28:55 2013 -0800 more time in stacks commit 4225219ccb422af33fdf54e81977ab50834a0452 Author: jackie Date: Fri Nov 22 22:44:54 2013 -0800 rainbow faces in order --- diff --git a/JackieBavaro.pde b/JackieBavaro.pde new file mode 100644 index 0000000..94ff518 --- /dev/null +++ b/JackieBavaro.pde @@ -0,0 +1,89 @@ +class JackieSquares extends SCPattern { + private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); + private BasicParameter maxSpreadParameter = new BasicParameter("SPREAD", 0.25); + private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); + private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); + private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); + + SinLFO hueMod = new SinLFO(0, 360, 4000); + SinLFO spreadMod = new SinLFO(1, 10, 8000); + + + class FaceFlash { + Face f; + float value; + float hue; + boolean hasPeaked; + + FaceFlash(int n) { + f = model.faces.get(n % model.faces.size()); + hue = random(360); + boolean infiniteAttack = (attackParameter.getValuef() > 0.999); + hasPeaked = infiniteAttack; + value = (infiniteAttack ? 1 : 0); + } + + // returns TRUE if this should die + boolean age(double ms) { + if (!hasPeaked) { + value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); + if (value >= 1.0) { + value = 1.0; + hasPeaked = true; + } + return false; + } else { + value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); + return value <= 0; + } + } + } + + private float leftoverMs = 0; + private List flashes; + private int faceNum = 0; + + public JackieSquares(GLucose glucose) { + super(glucose); + addParameter(rateParameter); + addParameter(attackParameter); + addParameter(decayParameter); + addParameter(saturationParameter); + addModulator(hueMod).trigger(); + addModulator(spreadMod).trigger(); + + flashes = new LinkedList(); + } + + public void run(double deltaMs) { + leftoverMs += deltaMs; + float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); + while (leftoverMs > msPerFlash) { + leftoverMs -= msPerFlash; + faceNum += int(spreadMod.getValuef()); + flashes.add(new FaceFlash(faceNum)); + } + + for (LXPoint p : model.points) { + colors[p.index] = 0; + } + + for (FaceFlash flash : flashes) { + float hue = (hueMod.getValuef() + flash.hue) % 360.0; + color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); + for (LXPoint p : flash.f.points) { + colors[p.index] = c; + } + } + + Iterator i = flashes.iterator(); + while (i.hasNext()) { + FaceFlash flash = i.next(); + boolean dead = flash.age(deltaMs); + if (dead) { + i.remove(); + } + } + } +} + diff --git a/SugarCubes.pde b/SugarCubes.pde index 40f9a76..8d9219d 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -65,6 +65,8 @@ LXPattern[] patterns(GLucose glucose) { // new TimTrace(glucose), new TimSpheres(glucose), + // Jackie + new JackieSquares(glucose), // Toby