Granim displaylist basics
authorBen Morrow <childoftv@gmail.com>
Sun, 18 Aug 2013 01:42:36 +0000 (18:42 -0700)
committerBen Morrow <childoftv@gmail.com>
Sun, 18 Aug 2013 01:42:36 +0000 (18:42 -0700)
BenMorrow.pde
GranimPattern.pde [new file with mode: 0644]
SugarCubes.pde

index 37cd99bee0518ec249546f873ad84a64d659f897..cf88145f061a5ddebf4846ae2bfb94521a6d59ce 100644 (file)
@@ -1,35 +1,56 @@
 class Sandbox extends SCPattern
 {
+       int c=0;
+       int prevC=0;
+       int huerange=255;
+       int pointrange= model.points.size();
+       int striprange= model.strips.size();
+       int facerange= model.faces.size();
+       int cuberange = model.cubes.size();
+       int towerrange = model.towers.size();
+       int counter=0;
 
        Sandbox(GLucose glucose) {
                super(glucose);
+               println("points "+pointrange);
+               println("strips "+striprange);
+               println("faces "+facerange);
+               println("cubes "+cuberange);
+               println("towers "+towerrange);
        }
-       int c=0;
-       int huerange=255;
-       int cuberange = 74;
-
-       int counter=0;
+       
        public void run(int deltaMs) {
-               Cube cube = model.cubes.get((int) c);
-               println("face length "+cube.faces.size());
-               if(cube.faces.size()!=4)
-               {
-                       for(Face f : cube.faces)
-                       {
-                       double col = Math.random()*255;
-                               for(Point p: f.points)
-                               {
-                                       colors[p.index] = color(Math.round(col),255,255);
-                               }
-                       }
-                               
-                       
-               }
-               if(counter% 3 ==0)
+               
+
+               if(counter % 10 ==0)
                {
-                       c = (c+1) % cuberange;
+                       doDraw(c,0);
+                       c = (c + 1) % towerrange;
+                       long col = color(Math.round(Math.random()*255),255,255) ;
+                       doDraw(c,col);
                }
                counter++;
-               println(c);
+
+       }
+
+       public void doDraw(int c,long col)
+       {
+                       Tower t= model.towers.get((int) c);
+                       for(Point p : t.points)
+                       {
+                               colors[p.index] = (int) col;
+                       }
        }
+};
+
+class GranimTestPattern extends GranimPattern
+{
+       GranimTestPattern(GLucose glucose)
+       {
+               super(glucose);
+               RedThreeGraphic myReds = new RedThreeGraphic();
+               addGraphic(myReds);
+       }
+
+
 }
\ No newline at end of file
diff --git a/GranimPattern.pde b/GranimPattern.pde
new file mode 100644 (file)
index 0000000..708a1ab
--- /dev/null
@@ -0,0 +1,57 @@
+class Graphic
+{
+       public int position  = 0;
+       public ArrayList<Integer> graphicBuffer;
+
+       Graphic()
+       {       
+               graphicBuffer = new ArrayList<Integer>();
+       }
+
+       
+};
+class GranimPattern extends SCPattern
+{
+       ArrayList<Graphic> displayList;
+
+       GranimPattern(GLucose glucose)
+       {
+               super(glucose);
+               displayList = new ArrayList<Graphic>();
+       }
+
+       public void addGraphic(Graphic g)
+       {
+               displayList.add(g);
+       }
+
+       public void run(int deltaMs) 
+       {
+               for(Graphic g : displayList)
+               {
+                       List<Point> drawList = model.points.subList(g.position, g.position + g.graphicBuffer.size());
+
+                       for (int i=0; i < drawList.size(); i++)
+                       {
+                               colors[drawList.get(i).index] = (int) g.graphicBuffer.get(i);
+                       }
+               }
+       }
+
+};
+
+class RedThreeGraphic extends Graphic
+{
+       RedThreeGraphic()
+       {
+               super();
+               prepare();
+       }
+       public void prepare()
+       {
+               for(int i=0; i < 3 ;i++)
+               {
+                       graphicBuffer.add(color(0,255,255));
+               }
+       }
+};
index 1d2de40910e4303d4ca29bdc902a0456f45a6a62..ae1976750348603c6db8eaf0de346505c3c395df 100644 (file)
@@ -25,6 +25,7 @@
 
 LXPattern[] patterns(GLucose glucose) {
   return new LXPattern[] {
+    new GranimTestPattern(glucose),
     new Sandbox(glucose),
     new HelixPattern(glucose),
     new ShiftingPlane(glucose),