From: Ben Morrow Date: Sun, 18 Aug 2013 01:42:36 +0000 (-0700) Subject: Granim displaylist basics X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fe0cb084e584265171877ae3ba421445eca78ecc;p=SugarCubes.git Granim displaylist basics --- diff --git a/BenMorrow.pde b/BenMorrow.pde index 37cd99b..cf88145 100644 --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -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 index 0000000..708a1ab --- /dev/null +++ b/GranimPattern.pde @@ -0,0 +1,57 @@ +class Graphic +{ + public int position = 0; + public ArrayList graphicBuffer; + + Graphic() + { + graphicBuffer = new ArrayList(); + } + + +}; +class GranimPattern extends SCPattern +{ + ArrayList displayList; + + GranimPattern(GLucose glucose) + { + super(glucose); + displayList = new ArrayList(); + } + + public void addGraphic(Graphic g) + { + displayList.add(g); + } + + public void run(int deltaMs) + { + for(Graphic g : displayList) + { + List 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)); + } + } +}; diff --git a/SugarCubes.pde b/SugarCubes.pde index 1d2de40..ae19767 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -25,6 +25,7 @@ LXPattern[] patterns(GLucose glucose) { return new LXPattern[] { + new GranimTestPattern(glucose), new Sandbox(glucose), new HelixPattern(glucose), new ShiftingPlane(glucose),