New LX fixes FlashEffect bug
[SugarCubes.git] / BenMorrow.pde
index a7f40da47f878c38c4c0fd6167bf4d5f77b74bf2..081da539b947c07ffcdc47d129d63eff3a7d7bf7 100644 (file)
@@ -1,3 +1,111 @@
+class XYZPixel extends SCPattern
+{
+       float xm = model.xMin;
+       float ym = model.yMin;
+       float zm = model.zMin;
+
+       float cubeWidth = 35;
+       float xm2 = model.xMin+cubeWidth;
+       float ym2 = model.yMin+cubeWidth;
+       float zm2 = model.zMin+cubeWidth;
+
+       XYZPixel(LX lx) {
+               super(lx);
+               //myP = new LXPoint(20,20,20);
+       }
+
+       void run(double deltaMs)
+       {
+               for(LXPoint p : model.points)
+               {
+                       if(p.x > xm && p.x<= xm2 && p.y > ym && p.y<= xm2 && p.z<= zm2 && p.z > zm)
+                       {
+                               colors[p.index] = lx.hsb(lx.getBaseHue()+100, 100, 100);
+                       
+                       }else{
+                               colors[p.index] = 0;
+                       }
+               }
+               float minIS=min(model.xMax,model.yMax,model.zMax);
+               xm = (xm + 1 ) % minIS;
+               ym = (ym + 1 ) % minIS;
+               zm = (zm + 1 ) % minIS;
+
+               xm2 = xm + cubeWidth;
+               ym2 = ym2 + cubeWidth;
+               zm2 = zm2 + cubeWidth;
+       }
+}
+
+class MultipleCubes extends SCPattern
+{
+       float xm = model.xMin;
+       float ym = model.yMin+10;
+       float zm = model.zMin+5;
+
+       float xma = model.xMin;
+       float xmb = model.xMin;
+
+       float cubeWidth = 35;
+
+       float minIS;
+
+       MultipleCubes(LX lx) {
+               super(lx);
+               minIS = 200;
+       }
+
+       void drawVirtualCube(float bottomX, float bottomY, float bottomZ, float side, int cubeColor)
+       {
+               for(LXPoint p : model.points)
+               {
+                       if(p.x > bottomX && p.x<= bottomX+side && p.y > bottomY && p.y<= bottomY + side  && p.z > bottomZ &&  p.z<= bottomZ+side)
+                       {
+                               colors[p.index] = cubeColor;
+                       }
+               }
+       }
+
+       void clear()
+       {
+               for(int i=0;i<colors.length;i++)
+               {
+                       colors[i]=0;
+               }
+       }
+       float side = 29.0;
+       int col;
+       int hueDo;
+       void run(double deltaMs)
+       {
+               boolean up = false;
+               clear();
+               for(int i = 0;i < model.yMax / side; i++)
+               {
+                       //println(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3)));
+                       if(i % 2 ==0)
+                       {
+                               xm = xma;
+                       }else{
+                               xm = xmb;
+                       }
+                       if(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3)) < side * 1.5)
+                       {
+                               hueDo = (hueDo+1) % 255;
+                               up = true;
+                       }
+                       col =  lx.hsb(lx.getBaseHue() + hueDo,100,100);
+                       drawVirtualCube(minIS-xm- 30*(i % 3), ym+i*side, zm, side, col);
+                       drawVirtualCube(xm + 30*(i % 3), ym+i*side, zm, side, col);
+               }
+               
+               xma = (xma + 7 ) % minIS;
+               xmb = (xmb + 3) % minIS;
+               //ym = (ym + 1 ) % minIS;
+               //zm = (zm + 1 ) % minIS;
+       }
+}
+
 class TowerParams extends SCPattern
 {
        BasicParameter hueoff = new BasicParameter("Hueoff", 0.0);
@@ -22,8 +130,8 @@ class TowerParams extends SCPattern
        ArrayList<BasicParameter> towerParams;
        int towerSize;
        int colorSpan;
-       TowerParams(GLucose glucose) {
-               super(glucose);
+       TowerParams(LX lx) {
+               super(lx);
 
                towerParams = new ArrayList<BasicParameter>();
                addParameter(hueoff);
@@ -50,21 +158,20 @@ class TowerParams extends SCPattern
                }
                towerSize = model.towers.size();
                colorSpan = 255 / towerSize;
-               println("towers "+towerSize);
        }
 
-       void run(int deltaMs)
+       void run(double deltaMs)
        {
                clearALL();
                Tower t;
                for(int i=0; i<towerSize ;i++)
                {       
                        t= model.towers.get(i);
-                       for(Point p : t.points)
+                       for(LXPoint p : t.points)
                        {
                                if(p.y<towerParams.get(i).getValuef()*200)
                                {
-                                       colors[p.index]=color(255 * hueoff.getValuef()+colorSpan * hueSpan.getValuef() * i,255,255);
+                                       colors[p.index]=lx.hsb(255 * hueoff.getValuef()+colorSpan * hueSpan.getValuef() * i, 255, 255);
                                }
                        }
                }
@@ -73,7 +180,7 @@ class TowerParams extends SCPattern
 
        public void clearALL()
        {
-               for(Point p : model.points)
+               for(LXPoint p : model.points)
                {
                        colors[p.index] = 0;
                }
@@ -92,8 +199,8 @@ class Sandbox extends SCPattern
        int towerrange = model.towers.size();
        int counter=0;
 
-       Sandbox(GLucose glucose) {
-               super(glucose);
+       Sandbox(LX lx) {
+               super(lx);
                println("points "+pointrange);
                println("strips "+striprange);
                println("faces "+facerange);
@@ -101,14 +208,14 @@ class Sandbox extends SCPattern
                println("towers "+towerrange);
        }
        
-       public void run(int deltaMs) {
+       public void run(double deltaMs) {
                
 
                if(counter % 10 ==0)
                {
                        doDraw(c,0);
                        c = (c + 1) % towerrange;
-                       long col = color(Math.round(Math.random()*255),255,255) ;
+                       long col = lx.hsb(Math.round(Math.random()*255),255,255) ;
                        doDraw(c,col);
                }
                counter++;
@@ -118,7 +225,7 @@ class Sandbox extends SCPattern
        public void doDraw(int c,long col)
        {
                        Tower t= model.towers.get((int) c);
-                       for(Point p : t.points)
+                       for(LXPoint p : t.points)
                        {
                                colors[p.index] = (int) col;
                        }
@@ -127,9 +234,9 @@ class Sandbox extends SCPattern
 
 class GranimTestPattern extends GranimPattern
 {
-       GranimTestPattern(GLucose glucose)
+       GranimTestPattern(LX lx)
        {
-               super(glucose);
+               super(lx);
                addGraphic("myReds",new RedsGraphic(100));
                int[] dots = {0,128,0,128,0,128,0,128,0,128,0,128};
                addGraphic("myOtherColors",new ColorDotsGraphic(dots));
@@ -137,7 +244,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);
@@ -163,9 +270,9 @@ class GranimTestPattern extends GranimPattern
 
 class GranimTestPattern2 extends GranimPattern
 {
-       GranimTestPattern2(GLucose glucose)
+       GranimTestPattern2(LX lx)
        {
-               super(glucose);
+               super(lx);
                /*for(int i = 0;i < 100; i++)
                {
                        Graphic g = addGraphic("myReds_"+i,new RedsGraphic(Math.round(Math.random() * 100)));
@@ -177,7 +284,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);
@@ -187,7 +294,7 @@ class GranimTestPattern2 extends GranimPattern
        }
        public void clearALL()
        {
-               for(Point p : model.points)
+               for(LXPoint p : model.points)
                {
                        colors[p.index] = 0;
                }
@@ -203,8 +310,8 @@ class DriveableCrossSections extends CrossSections
        BasicParameter zd;
        BasicParameter mode; 
 
-       DriveableCrossSections(GLucose glucose) {
-               super(glucose); 
+       DriveableCrossSections(LX lx) {
+               super(lx);      
        }
 
        public void addParams()
@@ -265,4 +372,4 @@ class DriveableCrossSections extends CrossSections
                }
        }
 
-}
\ No newline at end of file
+}