3 namespace PsychlopsSilverlight4test
\r
6 public class PsychlopsMain
\r
9 Psychlops.Canvas cnvs;
\r
11 double x, y, z, t, p, temp, xx, yy;
\r
13 //Set Target Initial Value
\r
14 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
16 //Set Background Initial Value
\r
17 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
18 Psychlops.Widgets.Slider thetaSpeed, DotNumber;
\r
22 public void psychlops_main()
\r
24 cnvs = new Canvas(500, 500);
\r
26 Interval rng = new Interval();
\r
27 thetaSpeed = new Psychlops.Widgets.Slider("Label" , -10 <= rng <= 10, 3.0);
\r
28 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
30 //Declare background dots and target
\r
31 Rectangle[] BGDot = new Rectangle[2048];
\r
32 for(int i=0; i<2048; i++){
\r
33 BGDot[i]=new Rectangle();
\r
35 Rectangle[] Target= new Rectangle[10];
\r
36 for(int i=0; i<10; i++){
\r
37 Target[i]=new Rectangle();
\r
41 //Declare Matrix to keep back ground dots' coordinate value
\r
42 double[] DotX=new double[2048];
\r
43 double[] DotY = new double[2048];
\r
46 //Set Independent variables to manipulate
\r
49 //Initialize positions of background dots
\r
50 for(int i=0; i<2048; i++){
\r
51 t=2.0*Math.PI*Math.random(1.0);
\r
52 p=2.0*Math.PI*Math.random(1.0);
\r
56 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
57 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
58 BGDot[i].set(BGSize, BGSize);
\r
59 BGDot[i].centering().shift(x,y);
\r
62 //Initialize positions of targets
\r
63 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
67 //Main stimulus loop
\r
69 //Clear the main window
\r
73 temp=Axis/360*2*Math.PI;
\r
77 //Calculate positions of background dots and set them
\r
78 for(int i=0; i<DotNumber; i++){
\r
79 //Calculate in polar coordinate
\r
80 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
83 //Save current position
\r
86 //Convert to Decartes coordinate
\r
87 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
88 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
89 z=BGRadii*Math.sin(p);
\r
93 //Set Dotsize and Draw them
\r
94 BGDot[i].set(BGSize, BGSize);
\r
95 BGDot[i].centering().shift(xx,yy);
\r
96 BGDot[i].draw( Color.blue );
\r
99 //Calculate positions of targets and set them
\r
100 temp=Rotate*2*Math.PI/360.0;
\r
101 for (int i = 0; i < 5; i++)
\r
103 t = 2.0 * Math.PI/TargetNumber;
\r
104 x = TargetEcce*Math.cos(i*t+temp);
\r
105 y = TargetEcce*Math.sin(i*t+temp);
\r
106 Target[i].centering().shift(x,y);
\r
107 Target[i].fill = Color.yellow;
\r
111 //Reflect drawing at the next frame;
\r
123 namespace PsychlopsSilverlight4test
\r
125 public class PsychlopsMain
\r
127 public void psychlops_main()
\r
129 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
130 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
131 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
132 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
133 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
134 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
135 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
136 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
138 Canvas window = new Canvas(300, 300);
\r
140 var figure_r = new Rectangle();
\r
141 var figure_e = new Ellipse();
\r
142 Shape figure = figure_r;
\r
144 while (!Keyboard.esc.pushed())
\r
146 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
148 figure_r.set(size_x, size_y);
\r
153 figure_e.set(size_x, size_y);
\r
156 figure.fill = new Color(color_r, color_g, color_b);
\r
158 window.clear(Color.black);
\r
159 figure.centering().shift(shift_x, shift_y).draw();
\r
173 namespace Psychlops
\r
176 public class RandomDots
\r
179 public Point[] cood;
\r
180 public RandomDots()
\r
182 cood = new Point[250];
\r
183 dot = new Rectangle(5, 5);
\r
187 dot.fill = Color.white;
\r
188 foreach (Point p in cood)
\r
190 dot.centering(p).draw();
\r
199 namespace PsychlopsSilverlight4test
\r
202 public class PsychlopsMain
\r
215 public void psychlops_main()
\r
217 cnvs = new Canvas(500, 500);
\r
219 img = new Image(isize * 2, isize * 2);
\r
220 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
223 fixation = new Ellipse(10, 10);
\r
224 fixation.fill = Color.red;
\r
225 //var poly = new Rectangle(100, 100);
\r
226 var poly = new Letters("日本語");
\r
227 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
228 //var poly = new Ellipse(100, 100);
\r
229 //var poly = new Line(0,0,100, 0);
\r
230 poly.fill = Color.red;
\r
231 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
234 var rng = new Interval();
\r
235 var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);
\r
237 dots = new RandomDots();
\r
245 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
246 col.set(Math.random(1.0));
\r
248 /*if (frames % 2 == 0)
\r
250 fixation.centering().shift(100, 100);
\r
251 fixation.draw(new Stroke(Color.blue, 3));
\r
254 fixation.centering().shift(slider, 0);
\r
255 fixation.draw(Color.red);
\r
257 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
258 //Figures.drawGaussian(ref img, 20, 1);
\r
259 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
260 //img.centering(Mouse.position);
\r
262 g.centering(Mouse.position).draw();
\r
265 shape.centering(Mouse.position).shift(100, 0);
\r
267 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
269 cnvs.var(frames, 0, 20);
\r
270 //slider.value = frames / 100.0;
\r
272 /*if (frames % 2 != 0)
\r
274 fixation.shift(100, 100);
\r
275 fixation.draw(new Stroke(Color.green, 3));
\r
278 for (int i = 0; i < dots.cood.Length; i++)
\r
280 dots.cood[i].set(Math.random(500), Math.random(500));
\r
282 cnvs.var((double)slider, 200, 200);
\r
297 namespace PsychlopsSilverlight4test
\r
300 public class PsychlopsMain
\r
306 public void psychlops_main()
\r
309 cnvs = new Canvas(500, 500);
\r
310 rect = new Rectangle[n];
\r
311 for (int i = 0; i < n; i++)
\r
313 rect[i] = new Rectangle(10, 10);
\r
314 rect[i].fill = Color.red;
\r
316 Interval rng = new Interval();
\r
317 var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);
\r
322 for (int i = 0; i < n; i++)
\r
324 rect[i].centering().shift(slider * i*3, i*3).draw();
\r