Now make it move
[SugarCubes.git] / GranimPattern.pde
1 import java.util.Hashtable;
2 class Graphic
3 {
4 public int position = 0;
5 public ArrayList<Integer> graphicBuffer;
6
7 Graphic()
8 {
9 graphicBuffer = new ArrayList<Integer>();
10 }
11
12
13 };
14 class GranimPattern extends SCPattern
15 {
16 Hashtable<String,Graphic> displayList;
17
18 GranimPattern(GLucose glucose)
19 {
20 super(glucose);
21 displayList = new Hashtable<String,Graphic>();
22 }
23
24 public void addGraphic(String name, Graphic g)
25 {
26 displayList.put(name,g);
27 }
28
29 public Graphic getGraphicByName(String name)
30 {
31 return displayList.get(name);
32 }
33
34 public void run(int deltaMs)
35 {
36 for(Graphic g : displayList.values())
37 {
38 List<Point> drawList = model.points.subList(g.position, g.position + g.graphicBuffer.size());
39
40 for (int i=0; i < drawList.size(); i++)
41 {
42 colors[drawList.get(i).index] = (int) g.graphicBuffer.get(i);
43 }
44 }
45 }
46
47 };
48
49 class RedThreeGraphic extends Graphic
50 {
51 RedThreeGraphic()
52 {
53 super();
54 prepare();
55 }
56 public void prepare()
57 {
58 for(int i=0; i < 3 ;i++)
59 {
60 graphicBuffer.add(color(0,255,255));
61 }
62 }
63 };