Better playability for the Rings pattern
[SugarCubes.git] / MicahScott.pde
index a9a747e1c19ccd4ed57115f8b12f5105fb934201..0eb967b62526e8b934023905a924a4d808b4ebcb 100644 (file)
@@ -2,45 +2,49 @@
 class Rings extends SCPattern {
 
     float dx, dy, dz;
-    float angleParam, hue, satParam, spacingParam;
+    float angleParam, spacingParam;
     float dzParam, centerParam;
 
-    BasicParameter pSpeed1 = new BasicParameter("SPD1", 0.15);
-    BasicParameter pSpeed2 = new BasicParameter("SPD2", 0.46);
-    BasicParameter pRGB = new BasicParameter("RGB", 0.73);
-    BasicParameter pScale = new BasicParameter("SCALE", 0.09);
-    BasicParameter pDepth = new BasicParameter("DEPTH", 0.40);
-    BasicParameter pBright = new BasicParameter("BRT", 0.66);    
-    BasicParameter pGamma = new BasicParameter("GAMMA", 0.12);    
+    BasicParameter pDepth = new BasicParameter("DEPTH", 0.6);
+    BasicParameter pBright = new BasicParameter("BRT", 0.75);    
+    BasicParameter pHue = new BasicParameter("HUE", 0.39);
+    BasicParameter pSaturation = new BasicParameter("SAT", 0.5);
+
+    BasicParameter pSpeed1 = new BasicParameter("SPD1", 0.2);
+    BasicParameter pSpeed2 = new BasicParameter("SPD2", 0.4);
+    BasicParameter pScale = new BasicParameter("SCALE", 0.15);
+
+    public Rings(LX lx) {
+        super(lx);
+        addParameter(pDepth);
+        addParameter(pBright);
+        addParameter(pHue);
+        addParameter(pSaturation);
 
-    public Rings(GLucose glucose) {
-        super(glucose);
         addParameter(pSpeed1);
         addParameter(pSpeed2);
         addParameter(pScale);
-        addParameter(pDepth);
-        addParameter(pRGB);
-        addParameter(pBright);
-        addParameter(pGamma);
     }
 
     public void run(double deltaMs) {
 
-        float xyspeed = pSpeed1.getValuef() * 0.004;
+        float xyspeed = pSpeed1.getValuef() * 0.01;
         float zspeed = pSpeed1.getValuef() * 0.08;
         float scale = pScale.getValuef() * 20.0;
+        float br = pBright.getValuef() * 3.0;
+        float gamma = 3.0;
+        float depth = 1.0 - pDepth.getValuef();
+        float hue = pHue.getValuef() * 360.0;
+        float saturation = pSaturation.getValuef() * 100;
 
         float angleSpeed = pSpeed1.getValuef() * 0.002;
         angleParam = (float)((angleParam + angleSpeed * deltaMs) % (2*PI));
         float angle = sin(angleParam);
 
-        hue += (deltaMs * pRGB.getValuef() * 0.3) % 360;
-        satParam += deltaMs * pRGB.getValuef() * 0.002;
-        spacingParam += deltaMs * pSpeed2.getValuef() * 0.0005;
+        spacingParam += deltaMs * pSpeed2.getValuef() * 0.001;
         dzParam += deltaMs * 0.000014;
-        centerParam += deltaMs * pSpeed2.getValuef() * 0.0005;
+        centerParam += deltaMs * pSpeed2.getValuef() * 0.001;
 
-        float saturation = 100 * constrain(pow(1.9 * noise(satParam), 2.5), 0, 1);
         float spacing = noise(spacingParam) * 50;
 
         dx += cos(angle) * xyspeed;
@@ -54,9 +58,6 @@ class Rings extends SCPattern {
         float coordMin = min(model.xMin, min(model.yMin, model.zMin));
         float coordMax = max(model.xMax, max(model.yMax, model.zMax));
 
-        float br = pBright.getValuef() * 3.0;
-        float gamma = pGamma.getValuef() * 20.0;
-
         for (LXPoint p : model.points) {
 
             // Scale while preserving aspect ratio
@@ -68,9 +69,14 @@ class Rings extends SCPattern {
             float pulse = (sin(dz + dist * spacing) - 0.3) * 0.6;
 
             noiseDetail(4);
-            float n = map(noise(dx + x*scale + pulse, dy + y*scale, dz + z*scale) - pDepth.getValuef(), 0, 1,
-                0, 2.0);
-            float m = map(noise(dx + x*scale, dy + y*scale, dz + z*scale), 0, 1, 0, 300);
+            float n = map(noise(dx + (x - centerx) * scale + centerx + pulse,
+                                dy + (y - centery) * scale + centery,
+                                dz + (z - centerz) * scale + centerz)
+                          - depth, 0, 1, 0, 2.0);
+            float m = map(noise(dx + (x - centerx) * scale + centerx,
+                                dy + (y - centery) * scale + centery,
+                                dz + (z - centerz) * scale + centerz),
+                          0, 1, 0, 300);
             noiseDetail(1);
 
             colors[p.index] = lx.hsb(