Change colors on Breathe
[SugarCubes.git] / BenMorrow.pde
index 911f886fef8661075837c690aa78f4ef0320d9b9..e610155120eced021237936582d2e4758d8c477e 100644 (file)
@@ -70,9 +70,9 @@ class GranimTestPattern extends GranimPattern
        }
        public void clearALL()
        {
-               for(Point p : model.points)
+               for(int i = 0; i < colors.length; i++)
                {
-                       colors[p.index] = 0;
+                       colors[i] = 0;
                }
        }
 
@@ -101,7 +101,7 @@ class GranimTestPattern2 extends GranimPattern
                super.run(deltaMs);
                Graphic randomsGraphic = getGraphicByName("myRandoms");
                randomsGraphic.position = Math.round(sin(count)*1000)+5000;
-               count+= 0.0005;
+               count+= 0.005;
        }
        public void clearALL()
        {
@@ -112,4 +112,75 @@ class GranimTestPattern2 extends GranimPattern
        }
 
 
+};
+
+class DriveableCrossSections extends CrossSections
+{
+       BasicParameter xd; 
+       BasicParameter yd;
+       BasicParameter zd;
+       BasicParameter mode; 
+
+       DriveableCrossSections(GLucose glucose) {
+               super(glucose); 
+       }
+
+       public void addParams()
+       {
+               mode = new BasicParameter("Mode", 0.0);
+               xd = new BasicParameter("XD", 0.0);
+               yd = new BasicParameter("YD", 0.0);
+               zd = new BasicParameter("ZD", 0.0);
+               addParameter(mode);
+               addParameter(xd);
+           addParameter(yd);
+           addParameter(zd);
+
+          super.addParams();
+       }
+
+       public void onParameterChanged(LXParameter p) {
+                       if(p == mode)
+                       {
+                               if(interactive())
+                               {
+                                       copyValuesToKnobs();
+                               }else{
+                                       copyKnobsToValues();
+                               }
+                       }
+       }
+
+       void copyValuesToKnobs()
+       {
+               xd.setValue(x.getValue()/200);
+               yd.setValue(y.getValue()/115);
+               zd.setValue(z.getValue()/100);
+       }
+
+       void copyKnobsToValues()
+       {
+               x.setValue(xd.getValue()*200);
+               y.setValue(yd.getValue()*115);
+               z.setValue(zd.getValue()*100);
+       }
+
+       boolean interactive()
+       {
+               return Math.round(mode.getValuef())>0.5;
+       }
+
+       public void updateXYZVals()
+       {
+               if(interactive())
+               {
+                       xv = xd.getValuef()*200;
+                   yv = yd.getValuef()*115;
+                   zv = zd.getValuef()*100;
+               }else{
+                       super.updateXYZVals();
+                       copyValuesToKnobs();
+               }
+       }
+
 }
\ No newline at end of file