From: Mark Slee Date: Thu, 19 Sep 2013 23:23:35 +0000 (-0700) Subject: Add speed slider, new HeronLX with deltaMs as double X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=34327c962351112e07c3d93f56ffc543fac45b58;p=SugarCubes.git Add speed slider, new HeronLX with deltaMs as double --- diff --git a/ArjunBanker.pde b/ArjunBanker.pde index dcd5fae..6af635a 100644 --- a/ArjunBanker.pde +++ b/ArjunBanker.pde @@ -13,7 +13,7 @@ class TelevisionStatic extends SCPattern { addParameter(hueParameter); } - void run(int deltaMs) { + void run(double deltaMs) { boolean d = direction.getValuef() > 5.0; for (Point p : model.points) { colors[p.index] = color((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100)); @@ -37,7 +37,7 @@ class AbstractPainting extends SCPattern { img.loadPixels(); } - void run(int deltaMs) { + void run(double deltaMs) { for (Point 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] = color(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.fz - brightMod.getValuef())/p.fz)); @@ -60,7 +60,7 @@ class Spirality extends SCPattern { } } - public void run(int deltaMs) { + public void run(double deltaMs) { angle += deltaMs * 0.007; rad += deltaMs * .025 * direction; float x = model.xMax / 2 + cos(angle) * rad; diff --git a/Audio.pde b/Audio.pde index 6e36a29..4547a74 100644 --- a/Audio.pde +++ b/Audio.pde @@ -57,7 +57,7 @@ public static class GraphicEQ { return avg; } - public void run(int deltaMs) { + public void run(double deltaMs) { fft.forward(lx.audioInput().mix); float zeroDBReference = pow(10, 100*(1-level.getValuef())/20.); float decibelRange = 12 + range.getValuef() * 60; diff --git a/BenMorrow.pde b/BenMorrow.pde old mode 100755 new mode 100644 index 87b22be..1eb8ae1 --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -53,7 +53,7 @@ class TowerParams extends SCPattern println("towers "+towerSize); } - void run(int deltaMs) + void run(double deltaMs) { clearALL(); Tower t; @@ -101,7 +101,7 @@ class Sandbox extends SCPattern println("towers "+towerrange); } - public void run(int deltaMs) { + public void run(double deltaMs) { if(counter % 10 ==0) @@ -137,7 +137,7 @@ class GranimTestPattern extends GranimPattern getGraphicByName("myOtherColors").position=100; } int counter=0; - public void run(int deltaMs) + public void run(double deltaMs) { clearALL(); super.run(deltaMs); @@ -177,7 +177,7 @@ class GranimTestPattern2 extends GranimPattern } int counter=0; float count=0; - public void run(int deltaMs) + public void run(double deltaMs) { clearALL(); super.run(deltaMs); diff --git a/DanKaminsky.pde b/DanKaminsky.pde index 0290786..3dd9d14 100644 --- a/DanKaminsky.pde +++ b/DanKaminsky.pde @@ -173,7 +173,7 @@ class OSC_Balls extends OSCPattern { balls[ballnum].y = msg.get(1).floatValue(); } - void run(int deltaMs){ + void run(double deltaMs){ for(Point p: model.points){ colors[p.index]=0; } for(int i=1; i 40) lx.tempo.setBpm(lx.tempo.bpm()/2); UpdateLights(); } - void StartRun(int deltaMs) { } + void StartRun(double deltaMs) { } color CalcPoint(xyz p) { return color(0,0,0); } float CalcCone (xyz v1, xyz v2, xyz c) { return degrees( acos ( v1.minus(c).dot(v2.minus(c)) / (sqrt(v1.minus(c).dot(v1.minus(c))) * sqrt(v2.minus(c).dot(v2.minus(c))) ) )); @@ -109,7 +109,7 @@ public class DPat extends SCPattern uiDebugText.setText(DanTextLine1, DanTextLine2); } - void run(int deltaMs) { + void run(double deltaMs) { NoiseMove += deltaMs; xdMax = model.xMax; ydMax = model.yMax; @@ -154,7 +154,7 @@ public class DPat extends SCPattern cNew = color( (hue(cNew) + modhue + zSpinHue - noizhue) % 360, saturation(cNew) + 100*s_Saturate(), - 100 * (s_Trails()==0 ? b : max(b, brightness(cOld)/100. - (1-s_Trails()) * deltaMs/200.)) + 100 * (s_Trails()==0 ? b : max(b, (float) (brightness(cOld)/100. - (1-s_Trails()) * deltaMs/200.))) * (s_Dim ()==0 ? 1 : 1-s_Dim()) ); diff --git a/GranimPattern.pde b/GranimPattern.pde old mode 100755 new mode 100644 index 425b97c..abe2237 --- a/GranimPattern.pde +++ b/GranimPattern.pde @@ -96,7 +96,7 @@ class GranimPattern extends SCPattern return displayList.get(name); } - public void run(int deltaMs) + public void run(double deltaMs) { drawToPointList(); } diff --git a/JR.pde b/JR.pde old mode 100755 new mode 100644 index ec0923f..cd494fa --- a/JR.pde +++ b/JR.pde @@ -39,7 +39,7 @@ class Gimbal extends SCPattern { float a = 0, b = 0, g = 0; - public void run(int deltaMs) { + public void run(double deltaMs) { if (DEBUG_MANUAL_ABG) { a = aP.getValuef() * (2 * PI); @@ -186,7 +186,7 @@ class Zebra extends SCPattern { return f > 0 ? 1 : 0; } - public void run(int deltaMs) { + public void run(double deltaMs) { float a = (millis() / 1000.f) % (2 * PI); float b = (millis() / 1200.f) % (2 * PI); float g = (millis() / 1600.f) % (2 * PI); diff --git a/JackStahl.pde b/JackStahl.pde old mode 100755 new mode 100644 index 05e2ec6..a840882 --- a/JackStahl.pde +++ b/JackStahl.pde @@ -34,7 +34,7 @@ class Swim extends SCPattern { int beat = 0; float prevRamp = 0; - void run(int deltaMs) { + void run(double deltaMs) { // Sync to the beat float ramp = (float)lx.tempo.ramp(); @@ -146,7 +146,7 @@ class Balance extends SCPattern { int beat = 0; float prevRamp = 0; - void run(int deltaMs) { + void run(double deltaMs) { // Sync to the beat float ramp = (float)lx.tempo.ramp(); diff --git a/MarkSlee.pde b/MarkSlee.pde index d22386a..9804b5c 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -28,7 +28,7 @@ class SpaceTime extends SCPattern { } } - void run(int deltaMs) { + void run(double deltaMs) { angle += deltaMs * 0.0007; float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle)); float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle)); @@ -84,7 +84,7 @@ class Swarm extends SCPattern { } } - void run(int deltaMs) { + void run(double deltaMs) { float s = 0; for (Strip strip : model.strips ) { int i = 0; @@ -93,7 +93,7 @@ class Swarm extends SCPattern { colors[p.index] = color( (lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360, constrain(80 + 40 * fV, 0, 100), - constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, (int) (offset.getValuef() * strip.metrics.numPoints), strip.metrics.numPoints), 0, 100) + constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100) ); ++i; } @@ -226,7 +226,7 @@ class BassPod extends SCPattern { } } - public void run(int deltaMs) { + public void run(double deltaMs) { eq.run(deltaMs); float bassLevel = eq.getAverageLevel(0, 5); @@ -276,7 +276,7 @@ class CubeEQ extends SCPattern { } } - public void run(int deltaMs) { + public void run(double deltaMs) { eq.run(deltaMs); float edgeConst = 2 + 30*edge.getValuef(); @@ -434,7 +434,7 @@ public class PianoKeyPattern extends SCPattern { getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start(); } - public void run(int deltaMs) { + public void run(double deltaMs) { int i = 0; float huef = lx.getBaseHuef(); float levelf = level.getValuef(); @@ -504,7 +504,7 @@ class CrossSections extends SCPattern { zv = z.getValuef(); } - public void run(int deltaMs) { + public void run(double deltaMs) { updateXYZVals(); float xlv = 100*xl.getValuef(); @@ -556,7 +556,7 @@ class Blinders extends SCPattern { s.modulateDurationBy(r); } - public void run(int deltaMs) { + public void run(double deltaMs) { float hv = lx.getBaseHuef(); int si = 0; for (Strip strip : model.strips) { @@ -591,7 +591,7 @@ class Psychedelia extends SCPattern { addModulator(c).trigger(); } - void run(int deltaMs) { + void run(double deltaMs) { float huev = h.getValuef(); float cv = c.getValuef(); float sv = s.getValuef(); @@ -627,7 +627,7 @@ class AskewPlanes extends SCPattern { addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger(); } - void run(int deltaMs) { + void run(double deltaMs) { av = a.getValuef(); bv = b.getValuef(); cv = c.getValuef(); @@ -646,7 +646,7 @@ class AskewPlanes extends SCPattern { } } - public void run(int deltaMs) { + public void run(double deltaMs) { float huev = lx.getBaseHuef(); // This is super fucking bizarre. But if this is a for loop, the framerate @@ -691,7 +691,7 @@ class ShiftingPlane extends SCPattern { addModulator(d).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { float hv = lx.getBaseHuef(); float av = a.getValuef(); float bv = b.getValuef(); @@ -747,7 +747,7 @@ class Traktor extends SCPattern { int counter = 0; - public void run(int deltaMs) { + public void run(double deltaMs) { eq.run(deltaMs); int stepThresh = (int) (40 - 39*speed.getValuef()); diff --git a/SamMorrow.pde b/SamMorrow.pde old mode 100755 new mode 100644 index 520ff29..0b70698 --- a/SamMorrow.pde +++ b/SamMorrow.pde @@ -11,7 +11,7 @@ class JazzRainbow extends SamPattern { } - public void run(int deltaMs) { + public void run(double deltaMs) { // Access the core master hue via this method call float hv = lx.getBaseHuef(); for (int i = 0; i < colors.length*5; i=i+27) { diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde old mode 100755 new mode 100644 index 2e9ead0..a9428aa --- a/ShaheenGandhi.pde +++ b/ShaheenGandhi.pde @@ -103,7 +103,7 @@ class HelixPattern extends SCPattern { return phase; } - void step(int deltaMs) { + void step(double deltaMs) { // Rotate if (rotationPeriod != 0) { this.phase = (phase + ((float)deltaMs / (float)rotationPeriod) * TWO_PI); @@ -243,7 +243,7 @@ class HelixPattern extends SCPattern { return color((lx.getBaseHuef() + (360*(phase / TWO_PI)))%360, 80.f, b); } - void run(int deltaMs) { + void run(double deltaMs) { boolean h1on = helix1On.getValue() > 0.5; boolean h2on = helix2On.getValue() > 0.5; boolean spokesOn = (float)basePairsOn.getValue() > 0.5; diff --git a/TestPatterns.pde b/TestPatterns.pde index b566e33..f8d59ee 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -10,7 +10,7 @@ class TestSpeakerMapping extends TestPattern { super(glucose); } - public void run(int deltaMs) { + public void run(double deltaMs) { int h = 0; for (Speaker speaker : model.speakers) { for (Strip strip : speaker.strips) { @@ -31,7 +31,7 @@ class TestBassMapping extends TestPattern { super(glucose); } - public void run(int deltaMs) { + public void run(double deltaMs) { int[] strips = { 2, 1, 0, 3, 13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6 }; int h = 0; for (int si : strips) { @@ -50,7 +50,7 @@ class TestFloorMapping extends TestPattern { super(glucose); } - public void run(int deltaMs) { + public void run(double deltaMs) { int[] strutIndices = {6, 5, 4, 3, 2, 1, 0, 7}; int h = 0; for (int si : strutIndices) { @@ -83,7 +83,7 @@ class TestStripPattern extends TestPattern { addModulator(d).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { for (Strip s : model.strips) { for (Point p : s.points) { colors[p.index] = color( @@ -105,7 +105,7 @@ class TestHuePattern extends TestPattern { super(glucose); } - public void run(int deltaMs) { + public void run(double deltaMs) { // Access the core master hue via this method call float hv = lx.getBaseHuef(); for (int i = 0; i < colors.length; ++i) { @@ -123,7 +123,7 @@ class TestXPattern extends TestPattern { super(glucose); addModulator(xPos).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { float hv = lx.getBaseHuef(); for (Point p : model.points) { // This is a common technique for modulating brightness. @@ -145,7 +145,7 @@ class TestYPattern extends TestPattern { super(glucose); addModulator(yPos).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { float hv = lx.getBaseHuef(); for (Point p : model.points) { float bv = max(0, 100 - abs(p.fy - yPos.getValuef())); @@ -163,7 +163,7 @@ class TestZPattern extends TestPattern { super(glucose); addModulator(zPos).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { float hv = lx.getBaseHuef(); for (Point p : model.points) { float bv = max(0, 100 - abs(p.fz - zPos.getValuef())); @@ -183,7 +183,7 @@ class TestTowerPattern extends TestPattern { addModulator(towerIndex).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { int ti = 0; for (Tower t : model.towers) { for (Point p : t.points) { @@ -230,7 +230,7 @@ class TestProjectionPattern extends TestPattern { addModulator(yPos).trigger(); } - public void run(int deltaMs) { + public void run(double deltaMs) { // For the same reasons described above, it may logically feel to you that // some of these operations are in reverse order. Again, just keep in mind that // the car itself is what's moving, not the object @@ -268,7 +268,7 @@ class TestCubePattern extends TestPattern { addModulator(index).start(); } - public void run(int deltaMs) { + public void run(double deltaMs) { for (Cube c : model.cubes) { int i = 0; for (Point p : c.points) { @@ -354,7 +354,7 @@ class MappingTool extends TestPattern { printInfo(); } - public void run(int deltaMs) { + public void run(double deltaMs) { color off = color(0, 0, 0); color c = off; color r = #FF0000; diff --git a/TimBavaro.pde b/TimBavaro.pde old mode 100755 new mode 100644 index 1dd062e..4da4b6e --- a/TimBavaro.pde +++ b/TimBavaro.pde @@ -41,7 +41,7 @@ class TimSpheres extends SCPattern { spheres[1].radius = 50; } - public void run(int deltaMs) { + public void run(double deltaMs) { // Access the core master hue via this method call float hv = hueParameter.getValuef(); float lfoValue = lfo.getValuef(); @@ -224,8 +224,8 @@ class TimRaindrops extends SCPattern { } // returns TRUE when this should die - boolean age(int ms) { - p.add(v, ms / 1000.0); + boolean age(double ms) { + p.add(v, (float) (ms / 1000.0)); return this.p.y < (0 - this.radius); } } @@ -239,7 +239,7 @@ class TimRaindrops extends SCPattern { raindrops = new LinkedList(); } - public void run(int deltaMs) { + public void run(double deltaMs) { leftoverMs += deltaMs; while (leftoverMs > msPerRaindrop) { leftoverMs -= msPerRaindrop; @@ -300,16 +300,16 @@ class TimCubes extends SCPattern { } // returns TRUE if this should die - boolean age(int ms) { + boolean age(double ms) { if (!hasPeaked) { - value = value + (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); + 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 - (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); + value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); return value <= 0; } } @@ -329,7 +329,7 @@ class TimCubes extends SCPattern { flashes = new LinkedList(); } - public void run(int deltaMs) { + public void run(double deltaMs) { leftoverMs += deltaMs; float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); while (leftoverMs > msPerFlash) { @@ -416,7 +416,7 @@ class TimPlanes extends SCPattern { float prevRamp = 0; float[] wobbleSpeeds = { 1.0/8, 1.0/4, 1.0/2, 1.0 }; - public void run(int deltaMs) { + public void run(double deltaMs) { float ramp = (float)lx.tempo.ramp(); if (ramp < prevRamp) { beat = (beat + 1) % 32; @@ -609,7 +609,7 @@ class TimPinwheels extends SCPattern { private float prevRamp = 0; - public void run(int deltaMs) { + public void run(double deltaMs) { float ramp = lx.tempo.rampf(); float numBeats = (1 + ramp - prevRamp) % 1; prevRamp = ramp; @@ -620,7 +620,7 @@ class TimPinwheels extends SCPattern { // 1 -> 180 float hueSpread = (hueSpreadParameter.getValuef() - 0.5) * 360; - float fadeAmount = (deltaMs / 1000.0) * pow(sharpnessParameter.getValuef() * 10, 1); + float fadeAmount = (float) (deltaMs / 1000.0) * pow(sharpnessParameter.getValuef() * 10, 1); for (Pinwheel pw : pinwheels) { pw.age(numBeats); @@ -816,7 +816,7 @@ class TimTrace extends SCPattern { return m; } - public void run(int deltaMs) { + public void run(double deltaMs) { for (Point p : model.points) { color c = colors[p.index]; colors[p.index] = color(hue(c), saturation(c), brightness(c) - 3); diff --git a/TobySegaran.pde b/TobySegaran.pde old mode 100755 new mode 100644 index 443be5b..32b6d82 --- a/TobySegaran.pde +++ b/TobySegaran.pde @@ -23,7 +23,7 @@ class GlitchPlasma extends SCPattern { } } - public void run(int deltaMs) { + public void run(double 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) @@ -67,7 +67,7 @@ class FireEffect extends SCPattern { float br=min(100,sqrt(level)*15); return color(level/1.7,100,br); } - public void run(int deltaMs) { + public void run(double deltaMs) { for (int x=10;x45 || x%50<5) { intensity[x][ym-1] = random(30,100); @@ -111,7 +111,7 @@ class StripBounce extends SCPattern { } } - public void run(int deltaMs) { + public void run(double deltaMs) { float[] bright = new float[model.points.size()]; for (Strip strip : model.strips) { for (int i=0;i midiListeners = new ArrayList(); // Display configuration mode boolean mappingMode = false; boolean debugMode = false; DebugUI debugUI; +boolean uiOn = true; +LXPattern restoreToPattern = null; // Handles to UI objects UIContext[] overlays; @@ -64,6 +67,9 @@ UIDebugText uiDebugText; // Camera variables float eyeR, eyeA, eyeX, eyeY, eyeZ, midX, midY, midZ; +/** + * Engine construction and initialization. + */ LXPattern[] _patterns(GLucose glucose) { LXPattern[] patterns = patterns(glucose); for (LXPattern p : patterns) { @@ -72,6 +78,12 @@ LXPattern[] _patterns(GLucose glucose) { return patterns; } +void logTime(String evt) { + int now = millis(); + println(evt + ": " + (now - lastMillis) + "ms"); + lastMillis = now; +} + void setup() { startMillis = lastMillis = millis(); @@ -113,11 +125,12 @@ void setup() { overlays = new UIContext[] { uiPatternA = new UIPatternDeck(lx.engine.getDeck(0), "PATTERN A", 4, 4, 140, 344), uiCrossfader = new UICrossfader(4, 352, 140, 212), + new UIOutput(4, 568, 140, 106), new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 344), new UIEffects(width-144, 352, 140, 144), new UITempo(width-144, 498, 140, 50), - new UIOutput(width-144, 552, 140, 106), + new UISpeed(width-144, 552, 140, 50), uiDebugText = new UIDebugText(4, height-64, width-8, 44), uiMapping = new UIMapping(mappingTool, 4, 4, 140, 344), @@ -126,8 +139,9 @@ void setup() { logTime("Built overlay UI"); // MIDI devices + midiListeners.add(new MidiListener().setEnabled(true)); for (MidiInputDevice d : RWMidi.getInputDevices()) { - d.createInput(this); + midiListeners.add(new MidiListener(d)); } SCMidiDevices.initializeStandardDevices(glucose); logTime("Setup MIDI devices"); @@ -150,31 +164,74 @@ void setup() { println("Hit the 'p' key to toggle Panda Board output"); } - -void controllerChangeReceived(rwmidi.Controller cc) { - if (debugMode) { +public class MidiListener { + private boolean enabled = false; + private final String name; + + MidiListener(MidiInputDevice d) { + d.createInput(this); + name = d.getName(); + } + + MidiListener() { + registerKeyEvent(this); + name = "Keyboard"; + } + + public String getName() { + return name; + } + + public void keyEvent(KeyEvent e) { + if (e.getID() == KeyEvent.KEY_PRESSED) { + switch (e.getKeyChar()) { + case 'q': + noteOnReceived(new Note(60, 127)); + break; + } + } else if (e.getID() == KeyEvent.KEY_RELEASED) { + switch (e.getKeyChar()) { + case 'q': + noteOffReceived(new Note(60, 0)); + break; + } + } + } + + public MidiListener setEnabled(boolean enabled) { + if (enabled != this.enabled) { + this.enabled = enabled; + // notify midi UI to update + } + return this; + } + + void controllerChangeReceived(rwmidi.Controller cc) { + if (!enabled) { + return; + } println("CC: " + cc.toString()); } -} -void noteOnReceived(Note note) { - if (debugMode) { + void noteOnReceived(Note note) { + if (!enabled) { + return; + } println("Note On: " + note.toString()); } -} -void noteOffReceived(Note note) { - if (debugMode) { + void noteOffReceived(Note note) { + if (!enabled) { + return; + } println("Note Off: " + note.toString()); } -} -void logTime(String evt) { - int now = millis(); - println(evt + ": " + (now - lastMillis) + "ms"); - lastMillis = now; } +/** + * Core render loop and drawing functionality. + */ void draw() { // Draws the simulation and the 2D UI overlay background(40); @@ -388,9 +445,9 @@ void drawUI() { } } -boolean uiOn = true; -LXPattern restoreToPattern = null; - +/** + * Top-level keyboard event handling + */ void keyPressed() { if (mappingMode) { mappingTool.keyPressed(uiMapping); @@ -434,6 +491,9 @@ void keyPressed() { } } +/** + * Top-level mouse event handling + */ int mx, my; void mousePressed() { boolean debugged = false; @@ -470,8 +530,6 @@ void mouseReleased() { for (UIContext context : overlays) { context.mouseReleased(mouseX, mouseY); } - - // ui.mouseReleased(); } void mouseWheel(int delta) { diff --git a/_UIFramework.pde b/_UIFramework.pde index ba5a8c8..3ca493b 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -602,11 +602,28 @@ public class UIParameterSlider extends UIParameterControl { } private boolean editing = false; + private long lastClick = 0; + private float doubleClickMode = 0; + private float doubleClickX = 0; protected void onMousePressed(float mx, float my) { + long now = millis(); float handleLeft = 4 + parameter.getValuef() * (w-8-handleWidth); if (mx >= handleLeft && mx < handleLeft + handleWidth) { editing = true; + } else { + if ((now - lastClick) < 300 && abs(mx - doubleClickX) < 3) { + parameter.setValue(doubleClickMode); + } + doubleClickX = mx; + if (mx < w*.25) { + doubleClickMode = 0; + } else if (mx > w*.75) { + doubleClickMode = 1; + } else { + doubleClickMode = 0.5; + } } + lastClick = now; } protected void onMouseReleased(float mx, float my) { diff --git a/_UIImplementation.pde b/_UIImplementation.pde index d25df48..c223444 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -459,6 +459,18 @@ class UIDebugText extends UIContext { } } +class UISpeed extends UIWindow { + UISpeed(float x, float y, float w, float h) { + super("SPEED", x, y, w, h); + new UIParameterSlider(4, titleHeight, w-10, 20) + .setParameter(new BasicParameter("SPEED", 0.5).addListener(new LXParameter.Listener() { + public void onParameterChanged(LXParameter parameter) { + lx.setSpeed(parameter.getValuef() * 2); + } + })).addToContainer(this); + } +} + String className(Object p, String suffix) { String s = p.getClass().getName(); int li; diff --git a/code/HeronLX.jar b/code/HeronLX.jar index a163fc9..5a98f5e 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ