Moving helix down as slow for now
[SugarCubes.git] / BenMorrow.pde
CommitLineData
a68abe8c
BM
1class Sandbox extends SCPattern
2{
fe0cb084
BM
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;
a68abe8c 12
47011215 13 Sandbox(GLucose glucose) {
a68abe8c 14 super(glucose);
fe0cb084
BM
15 println("points "+pointrange);
16 println("strips "+striprange);
17 println("faces "+facerange);
18 println("cubes "+cuberange);
19 println("towers "+towerrange);
a68abe8c 20 }
fe0cb084 21
a68abe8c 22 public void run(int deltaMs) {
fe0cb084
BM
23
24
25 if(counter % 10 ==0)
a68abe8c 26 {
fe0cb084
BM
27 doDraw(c,0);
28 c = (c + 1) % towerrange;
29 long col = color(Math.round(Math.random()*255),255,255) ;
30 doDraw(c,col);
a68abe8c
BM
31 }
32 counter++;
fe0cb084
BM
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 }
a68abe8c 43 }
fe0cb084
BM
44};
45
46class GranimTestPattern extends GranimPattern
47{
48 GranimTestPattern(GLucose glucose)
49 {
50 super(glucose);
3b85aef4
BM
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;
27e9754c
BM
56 }
57 int counter=0;
58 public void run(int deltaMs)
59 {
3b85aef4 60 clearALL();
27e9754c 61 super.run(deltaMs);
3b85aef4 62
27e9754c
BM
63 if(counter % 3 ==0)
64 {
3b85aef4
BM
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 {
cd059b79 73 for(int i = 0; i < colors.length; i++)
3b85aef4 74 {
cd059b79 75 colors[i] = 0;
3b85aef4
BM
76 }
77 }
78
79
80}
81
82class 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;
cd059b79 104 count+= 0.005;
3b85aef4
BM
105 }
106 public void clearALL()
107 {
108 for(Point p : model.points)
109 {
110 colors[p.index] = 0;
27e9754c 111 }
fe0cb084
BM
112 }
113
114
a1d396e5
BM
115};
116
117class DriveableCrossSections extends CrossSections
118{
e1635ff6
BM
119 BasicParameter xd;
120 BasicParameter yd;
121 BasicParameter zd;
122 BasicParameter mode;
a1d396e5
BM
123
124 DriveableCrossSections(GLucose glucose) {
125 super(glucose);
126 }
127
128 public void addParams()
129 {
e1635ff6
BM
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);
a1d396e5
BM
135 addParameter(xd);
136 addParameter(yd);
137 addParameter(zd);
138 addParameter(xr);
139 addParameter(yr);
140 addParameter(zr);
141 addParameter(xw);
142 addParameter(xl);
143 addParameter(yl);
144 addParameter(zl);
145 addParameter(yw);
146 addParameter(zw);
147 }
148
e1635ff6
BM
149 public void onParameterChanged(LXParameter p) {
150 if(p == mode)
151 {
152 if(interactive())
153 {
154 xd.setValue(x.getValue()/200);
155 yd.setValue(y.getValue()/200);
156 zd.setValue(z.getValue()/100);
157 }
158 }
159 }
a1d396e5 160
e1635ff6
BM
161 boolean interactive()
162 {
163 return Math.round(mode.getValuef())>0.5;
164 }
a1d396e5
BM
165
166 public void updateXYZVals()
167 {
e1635ff6
BM
168 if(interactive())
169 {
170 xv = xd.getValuef()*200;
171 yv = yd.getValuef()*200;
172 zv = zd.getValuef()*100;
173 }else{
174 super.updateXYZVals();
175 }
a1d396e5
BM
176 }
177
a68abe8c 178}