use a hashtable so we can name graphic instances
[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 void run(int deltaMs)
30 {
31 for(Graphic g : displayList.values())
32 {
33 List<Point> drawList = model.points.subList(g.position, g.position + g.graphicBuffer.size());
34
35 for (int i=0; i < drawList.size(); i++)
36 {
37 colors[drawList.get(i).index] = (int) g.graphicBuffer.get(i);
38 }
39 }
40 }
41
42 };
43
44 class RedThreeGraphic extends Graphic
45 {
46 RedThreeGraphic()
47 {
48 super();
49 prepare();
50 }
51 public void prepare()
52 {
53 for(int i=0; i < 3 ;i++)
54 {
55 graphicBuffer.add(color(0,255,255));
56 }
57 }
58 };