4 namespace PsychlopsSilverlight4test
\r
7 public class PsychlopsMain
\r
10 Psychlops.Widgets.Slider rect_size;
\r
11 Psychlops.Widgets.Slider rect_lum;
\r
12 Psychlops.Widgets.Slider bg_lum;
\r
15 void RectLuminance()
\r
17 Canvas display = new Canvas(Canvas.window);
\r
18 Interval rng = new Interval();
\r
19 rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 10.0);
\r
20 rect_lum = new Psychlops.Widgets.Slider("Rect Luminance", 0.0 <= rng <= 1.0, 0.1);
\r
21 bg_lum = new Psychlops.Widgets.Slider("BG Luminance", 0.0 <= rng <= 1.0, 0.1);
\r
22 Ellipse drawee = new Ellipse(100, 100);
\r
26 Rectangle rect = new Rectangle(rect_size, rect_size);
\r
30 Clock before = new Clock(), after = new Clock();
\r
31 while (!Keyboard.esc.pushed())
\r
33 Display.clear(bg_lum);
\r
34 rect.resize(rect_size, rect_size).draw(rect_lum);
\r
36 display.var((after - before).at_msec(), 100, 100, Color.green);
\r
37 display.var((after - before).at_msec(), 100, 200, Color.green);
\r
38 drawee.centering().shift(Math.random(100), 0);
\r
39 drawee.draw(Color.black);
\r
46 public void psychlops_main()
\r
69 namespace PsychlopsSilverlight4test
\r
72 public class PsychlopsMain
\r
75 Psychlops.Canvas cnvs;
\r
77 double x, y, z, t, p, temp, xx, yy;
\r
79 //Set Target Initial Value
\r
80 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
82 //Set Background Initial Value
\r
83 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
84 Psychlops.Widgets.Slider thetaSpeed, DotNumber;
\r
89 public void psychlops_main()
\r
91 cnvs = new Canvas(500, 500);
\r
93 Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);
\r
96 img = new Image("Resources/logo.png");
\r
98 Interval rng = new Interval();
\r
99 thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);
\r
100 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
102 //Declare background dots and target
\r
103 Rectangle[] BGDot = new Rectangle[2048];
\r
104 for(int i=0; i<2048; i++){
\r
105 BGDot[i]=new Rectangle();
\r
107 Rectangle[] Target= new Rectangle[10];
\r
108 for(int i=0; i<10; i++){
\r
109 Target[i]=new Rectangle();
\r
113 //Declare Matrix to keep back ground dots' coordinate value
\r
114 double[] DotX=new double[2048];
\r
115 double[] DotY = new double[2048];
\r
118 //Set Independent variables to manipulate
\r
121 //Initialize positions of background dots
\r
122 for(int i=0; i<2048; i++){
\r
123 t=2.0*Math.PI*Math.random(1.0);
\r
124 p=2.0*Math.PI*Math.random(1.0);
\r
128 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
129 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
130 BGDot[i].set(BGSize, BGSize);
\r
131 BGDot[i].centering().shift(x,y);
\r
134 //Initialize positions of targets
\r
135 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
139 //Main stimulus loop
\r
141 //Clear the main window
\r
145 temp=Axis/360*2*Math.PI;
\r
146 COS=Math.cos(temp);
\r
147 SIN=Math.sin(temp);
\r
149 //Calculate positions of background dots and set them
\r
150 for(int i=0; i<DotNumber; i++){
\r
151 //Calculate in polar coordinate
\r
152 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
155 //Save current position
\r
158 //Convert to Decartes coordinate
\r
159 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
160 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
161 z=BGRadii*Math.sin(p);
\r
165 //Set Dotsize and Draw them
\r
166 BGDot[i].set(BGSize, BGSize);
\r
167 BGDot[i].centering().shift(xx,yy);
\r
168 BGDot[i].draw( Color.blue );
\r
171 //Calculate positions of targets and set them
\r
172 temp=Rotate*2*Math.PI/360.0;
\r
173 for (int i = 0; i < 5; i++)
\r
175 t = 2.0 * Math.PI/TargetNumber;
\r
176 x = TargetEcce*Math.cos(i*t+temp);
\r
177 y = TargetEcce*Math.sin(i*t+temp);
\r
178 Target[i].centering().shift(x,y);
\r
179 Target[i].fill = Color.yellow;
\r
183 img.centering(Mouse.position).draw();
\r
185 cnvs.var(Mouse.position.x, 100, 100);
\r
186 cnvs.var(Mouse.position.y, 100, 140);
\r
188 //Reflect drawing at the next frame;
\r
200 namespace PsychlopsSilverlight4test
\r
202 public class PsychlopsMain
\r
204 public void psychlops_main()
\r
206 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
207 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
208 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
209 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
210 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
211 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
212 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
213 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
215 Canvas window = new Canvas(300, 300);
\r
217 var figure_r = new Rectangle();
\r
218 var figure_e = new Ellipse();
\r
219 Shape figure = figure_r;
\r
221 while (!Keyboard.esc.pushed())
\r
223 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
225 figure_r.set(size_x, size_y);
\r
230 figure_e.set(size_x, size_y);
\r
233 figure.fill = new Color(color_r, color_g, color_b);
\r
235 window.clear(Color.black);
\r
236 figure.centering().shift(shift_x, shift_y).draw();
\r
250 namespace Psychlops
\r
253 public class RandomDots
\r
256 public Point[] cood;
\r
257 public RandomDots()
\r
259 cood = new Point[250];
\r
260 dot = new Rectangle(5, 5);
\r
264 dot.fill = Color.white;
\r
265 foreach (Point p in cood)
\r
267 dot.centering(p).draw();
\r
276 namespace PsychlopsSilverlight4test
\r
279 public class PsychlopsMain
\r
292 public void psychlops_main()
\r
294 cnvs = new Canvas(500, 500);
\r
296 img = new Image(isize * 2, isize * 2);
\r
297 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
300 fixation = new Ellipse(10, 10);
\r
301 fixation.fill = Color.red;
\r
302 //var poly = new Rectangle(100, 100);
\r
303 var poly = new Letters("日本語");
\r
304 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
305 //var poly = new Ellipse(100, 100);
\r
306 //var poly = new Line(0,0,100, 0);
\r
307 poly.fill = Color.red;
\r
308 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
311 var rng = new Interval();
\r
312 var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);
\r
314 dots = new RandomDots();
\r
322 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
323 col.set(Math.random(1.0));
\r
325 /*if (frames % 2 == 0)
\r
327 fixation.centering().shift(100, 100);
\r
328 fixation.draw(new Stroke(Color.blue, 3));
\r
331 fixation.centering().shift(slider, 0);
\r
332 fixation.draw(Color.red);
\r
334 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
335 //Figures.drawGaussian(ref img, 20, 1);
\r
336 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
337 //img.centering(Mouse.position);
\r
339 g.centering(Mouse.position).draw();
\r
342 shape.centering(Mouse.position).shift(100, 0);
\r
344 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
346 cnvs.var(frames, 0, 20);
\r
347 //slider.value = frames / 100.0;
\r
349 /*if (frames % 2 != 0)
\r
351 fixation.shift(100, 100);
\r
352 fixation.draw(new Stroke(Color.green, 3));
\r
355 for (int i = 0; i < dots.cood.Length; i++)
\r
357 dots.cood[i].set(Math.random(500), Math.random(500));
\r
359 cnvs.var((double)slider, 200, 200);
\r
374 namespace PsychlopsSilverlight4test
\r
377 public class PsychlopsMain
\r
383 public void psychlops_main()
\r
386 cnvs = new Canvas(500, 500);
\r
387 rect = new Rectangle[n];
\r
388 for (int i = 0; i < n; i++)
\r
390 rect[i] = new Rectangle(10, 10);
\r
391 rect[i].fill = Color.red;
\r
393 Interval rng = new Interval();
\r
394 var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);
\r
399 for (int i = 0; i < n; i++)
\r
401 rect[i].centering().shift(slider * i*3, i*3).draw();
\r