Merge branch 'master' of github.com:sugarcubes/SugarCubes into integration
[SugarCubes.git] / BenMorrow.pde
1 class Sandbox extends SCPattern
2 {
3 int c=0;
4 int prevC=0;
5 int huerange=255;
6 int pointrange= model.points.size();
7 int striprange= model.strips.size();
8 int facerange= model.faces.size();
9 int cuberange = model.cubes.size();
10 int towerrange = model.towers.size();
11 int counter=0;
12
13 Sandbox(GLucose glucose) {
14 super(glucose);
15 println("points "+pointrange);
16 println("strips "+striprange);
17 println("faces "+facerange);
18 println("cubes "+cuberange);
19 println("towers "+towerrange);
20 }
21
22 public void run(int deltaMs) {
23
24
25 if(counter % 10 ==0)
26 {
27 doDraw(c,0);
28 c = (c + 1) % towerrange;
29 long col = color(Math.round(Math.random()*255),255,255) ;
30 doDraw(c,col);
31 }
32 counter++;
33
34 }
35
36 public void doDraw(int c,long col)
37 {
38 Tower t= model.towers.get((int) c);
39 for(Point p : t.points)
40 {
41 colors[p.index] = (int) col;
42 }
43 }
44 };
45
46 class GranimTestPattern extends GranimPattern
47 {
48 GranimTestPattern(GLucose glucose)
49 {
50 super(glucose);
51 addGraphic("myReds",new RedsGraphic(100));
52 int[] dots = {0,128,0,128,0,128,0,128,0,128,0,128};
53 addGraphic("myOtherColors",new ColorDotsGraphic(dots));
54
55 getGraphicByName("myOtherColors").position=100;
56 }
57 int counter=0;
58 public void run(int deltaMs)
59 {
60 clearALL();
61 super.run(deltaMs);
62
63 if(counter % 3 ==0)
64 {
65 Graphic reds = getGraphicByName("myReds");
66 Graphic others = getGraphicByName("myOtherColors");
67 reds.position = reds.position + 1 % 19000;
68 others.position = others.position + 10 % 19000;
69 }
70 }
71 public void clearALL()
72 {
73 for(int i = 0; i < colors.length; i++)
74 {
75 colors[i] = 0;
76 }
77 }
78
79
80 }
81
82 class GranimTestPattern2 extends GranimPattern
83 {
84 GranimTestPattern2(GLucose glucose)
85 {
86 super(glucose);
87 /*for(int i = 0;i < 100; i++)
88 {
89 Graphic g = addGraphic("myReds_"+i,new RedsGraphic(Math.round(Math.random() * 100)));
90
91 }*/
92 Graphic g = addGraphic("myRandoms",new RandomsGranim(50));
93 g.position = 200;
94
95 }
96 int counter=0;
97 float count=0;
98 public void run(int deltaMs)
99 {
100 clearALL();
101 super.run(deltaMs);
102 Graphic randomsGraphic = getGraphicByName("myRandoms");
103 randomsGraphic.position = Math.round(sin(count)*1000)+5000;
104 count+= 0.005;
105 }
106 public void clearALL()
107 {
108 for(Point p : model.points)
109 {
110 colors[p.index] = 0;
111 }
112 }
113
114
115 };
116
117 class DriveableCrossSections extends CrossSections
118 {
119 BasicParameter xd;
120 BasicParameter yd;
121 BasicParameter zd;
122 BasicParameter mode;
123
124 DriveableCrossSections(GLucose glucose) {
125 super(glucose);
126 }
127
128 public void addParams()
129 {
130 mode = new BasicParameter("Mode", 0.0);
131 xd = new BasicParameter("XD", 0.0);
132 yd = new BasicParameter("YD", 0.0);
133 zd = new BasicParameter("ZD", 0.0);
134 addParameter(mode);
135 addParameter(xd);
136 addParameter(yd);
137 addParameter(zd);
138
139 super.addParams();
140 }
141
142 public void onParameterChanged(LXParameter p) {
143 if(p == mode)
144 {
145 if(interactive())
146 {
147 copyValuesToKnobs();
148 }else{
149 copyKnobsToValues();
150 }
151 }
152 }
153
154 void copyValuesToKnobs()
155 {
156 xd.setValue(x.getValue()/200);
157 yd.setValue(y.getValue()/115);
158 zd.setValue(z.getValue()/100);
159 }
160
161 void copyKnobsToValues()
162 {
163 x.setValue(xd.getValue()*200);
164 y.setValue(yd.getValue()*115);
165 z.setValue(zd.getValue()*100);
166 }
167
168 boolean interactive()
169 {
170 return Math.round(mode.getValuef())>0.5;
171 }
172
173 public void updateXYZVals()
174 {
175 if(interactive())
176 {
177 xv = xd.getValuef()*200;
178 yv = yd.getValuef()*115;
179 zv = zd.getValuef()*100;
180 }else{
181 super.updateXYZVals();
182 copyValuesToKnobs();
183 }
184 }
185
186 }