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
23 public void psychlops_main()
\r
25 cnvs = new Canvas(500, 500);
\r
28 img = new Image("Resources/logo.png");
\r
30 Interval rng = new Interval();
\r
31 thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);
\r
32 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
34 //Declare background dots and target
\r
35 Rectangle[] BGDot = new Rectangle[2048];
\r
36 for(int i=0; i<2048; i++){
\r
37 BGDot[i]=new Rectangle();
\r
39 Rectangle[] Target= new Rectangle[10];
\r
40 for(int i=0; i<10; i++){
\r
41 Target[i]=new Rectangle();
\r
45 //Declare Matrix to keep back ground dots' coordinate value
\r
46 double[] DotX=new double[2048];
\r
47 double[] DotY = new double[2048];
\r
50 //Set Independent variables to manipulate
\r
53 //Initialize positions of background dots
\r
54 for(int i=0; i<2048; i++){
\r
55 t=2.0*Math.PI*Math.random(1.0);
\r
56 p=2.0*Math.PI*Math.random(1.0);
\r
60 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
61 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
62 BGDot[i].set(BGSize, BGSize);
\r
63 BGDot[i].centering().shift(x,y);
\r
66 //Initialize positions of targets
\r
67 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
71 //Main stimulus loop
\r
73 //Clear the main window
\r
77 temp=Axis/360*2*Math.PI;
\r
81 //Calculate positions of background dots and set them
\r
82 for(int i=0; i<DotNumber; i++){
\r
83 //Calculate in polar coordinate
\r
84 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
87 //Save current position
\r
90 //Convert to Decartes coordinate
\r
91 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
92 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
93 z=BGRadii*Math.sin(p);
\r
97 //Set Dotsize and Draw them
\r
98 BGDot[i].set(BGSize, BGSize);
\r
99 BGDot[i].centering().shift(xx,yy);
\r
100 BGDot[i].draw( Color.blue );
\r
103 //Calculate positions of targets and set them
\r
104 temp=Rotate*2*Math.PI/360.0;
\r
105 for (int i = 0; i < 5; i++)
\r
107 t = 2.0 * Math.PI/TargetNumber;
\r
108 x = TargetEcce*Math.cos(i*t+temp);
\r
109 y = TargetEcce*Math.sin(i*t+temp);
\r
110 Target[i].centering().shift(x,y);
\r
111 Target[i].fill = Color.yellow;
\r
115 img.centering(Mouse.position).draw();
\r
117 cnvs.var(Mouse.position.x, 100, 100);
\r
118 cnvs.var(Mouse.position.y, 100, 140);
\r
120 //Reflect drawing at the next frame;
\r
132 namespace PsychlopsSilverlight4test
\r
134 public class PsychlopsMain
\r
136 public void psychlops_main()
\r
138 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
139 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
140 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
141 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
142 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
143 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
144 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
145 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
147 Canvas window = new Canvas(300, 300);
\r
149 var figure_r = new Rectangle();
\r
150 var figure_e = new Ellipse();
\r
151 Shape figure = figure_r;
\r
153 while (!Keyboard.esc.pushed())
\r
155 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
157 figure_r.set(size_x, size_y);
\r
162 figure_e.set(size_x, size_y);
\r
165 figure.fill = new Color(color_r, color_g, color_b);
\r
167 window.clear(Color.black);
\r
168 figure.centering().shift(shift_x, shift_y).draw();
\r
182 namespace Psychlops
\r
185 public class RandomDots
\r
188 public Point[] cood;
\r
189 public RandomDots()
\r
191 cood = new Point[250];
\r
192 dot = new Rectangle(5, 5);
\r
196 dot.fill = Color.white;
\r
197 foreach (Point p in cood)
\r
199 dot.centering(p).draw();
\r
208 namespace PsychlopsSilverlight4test
\r
211 public class PsychlopsMain
\r
224 public void psychlops_main()
\r
226 cnvs = new Canvas(500, 500);
\r
228 img = new Image(isize * 2, isize * 2);
\r
229 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
232 fixation = new Ellipse(10, 10);
\r
233 fixation.fill = Color.red;
\r
234 //var poly = new Rectangle(100, 100);
\r
235 var poly = new Letters("日本語");
\r
236 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
237 //var poly = new Ellipse(100, 100);
\r
238 //var poly = new Line(0,0,100, 0);
\r
239 poly.fill = Color.red;
\r
240 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
243 var rng = new Interval();
\r
244 var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);
\r
246 dots = new RandomDots();
\r
254 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
255 col.set(Math.random(1.0));
\r
257 /*if (frames % 2 == 0)
\r
259 fixation.centering().shift(100, 100);
\r
260 fixation.draw(new Stroke(Color.blue, 3));
\r
263 fixation.centering().shift(slider, 0);
\r
264 fixation.draw(Color.red);
\r
266 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
267 //Figures.drawGaussian(ref img, 20, 1);
\r
268 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
269 //img.centering(Mouse.position);
\r
271 g.centering(Mouse.position).draw();
\r
274 shape.centering(Mouse.position).shift(100, 0);
\r
276 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
278 cnvs.var(frames, 0, 20);
\r
279 //slider.value = frames / 100.0;
\r
281 /*if (frames % 2 != 0)
\r
283 fixation.shift(100, 100);
\r
284 fixation.draw(new Stroke(Color.green, 3));
\r
287 for (int i = 0; i < dots.cood.Length; i++)
\r
289 dots.cood[i].set(Math.random(500), Math.random(500));
\r
291 cnvs.var((double)slider, 200, 200);
\r
306 namespace PsychlopsSilverlight4test
\r
309 public class PsychlopsMain
\r
315 public void psychlops_main()
\r
318 cnvs = new Canvas(500, 500);
\r
319 rect = new Rectangle[n];
\r
320 for (int i = 0; i < n; i++)
\r
322 rect[i] = new Rectangle(10, 10);
\r
323 rect[i].fill = Color.red;
\r
325 Interval rng = new Interval();
\r
326 var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);
\r
331 for (int i = 0; i < n; i++)
\r
333 rect[i].centering().shift(slider * i*3, i*3).draw();
\r