5 namespace PsychlopsSilverlight4test
\r
8 public class PsychlopsMain
\r
10 void RectLuminance()
\r
12 Canvas display = new Canvas(Canvas.window);
\r
13 Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);
\r
14 Letters le = new Letters("Reload to restart");
\r
15 le.fill = Color.black;
\r
16 le.align = Letters.HorizontalAlign.center;
\r
18 while (!Keyboard.esc.pushed())
\r
20 Display.clear(Color.white);
\r
21 le.centering().shift(-200,-10).draw();
\r
28 public void psychlops_main()
\r
45 namespace PsychlopsSilverlightApp
\r
48 public class PsychlopsMain
\r
51 Psychlops.Widgets.Slider rect_size, freq, contrast;
\r
53 void PositionalBiasisInMovingGabor()
\r
56 double StimWidth = 120;
\r
58 Interval rng = new Interval();
\r
59 Psychlops.Widgets.Slider rect_size, freq, contrast;
\r
60 rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 120.0);
\r
61 freq = new Psychlops.Widgets.Slider("Sptial Frequency", 0.0 <= rng <= 1.0, 0.125);
\r
62 contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.1);
\r
64 int IMAGES = (int)vel;
\r
66 Image[] GaborIMG = new Image[200];
\r
67 for (int i = 0; i < 200; i++) GaborIMG[i] = new Image();
\r
69 Color clrcol = new Color(), clrFP = new Color();
\r
71 clrcol.set(128.0 / 255.0);
\r
72 clrFP.set(128.0 / 255.0, 0.0, 0.0);
\r
75 double distance = rect_size;
\r
76 bool changed = true, stop = false;
\r
77 double prev_contrast = 0.0, prev_freq = 0.0, prev_size = 0.0;
\r
79 while (!Keyboard.esc.pushed())
\r
83 if (prev_contrast != contrast || prev_freq != freq || prev_size != rect_size) changed = true;
\r
84 prev_contrast = contrast;
\r
86 prev_size = rect_size;
\r
89 for (int i = 0; i < 2; i++)
\r
91 for (int j = 0; j < IMAGES; j++)
\r
93 Figures.drawGabor(ref GaborIMG[i * IMAGES + j], rect_size / 8.0, freq, contrast, Math.PI * 0.5, 2.0 * Math.PI * j / IMAGES);
\r
94 distance = rect_size;
\r
102 Display.clear(127.0 / 255.0);
\r
103 for (int i = 0; i < 3; i++)
\r
108 GaborIMG[IMAGES - phase - 1].centering().shift(0, -distance);
\r
109 GaborIMG[IMAGES - phase - 1].draw(); break;
\r
111 GaborIMG[phase].centering().shift(0, 0);
\r
112 GaborIMG[phase].draw(); break;
\r
114 GaborIMG[IMAGES - phase - 1].centering().shift(0, +distance);
\r
115 GaborIMG[IMAGES - phase - 1].draw(); break;
\r
119 if (Keyboard.spc.pushed()) stop = !stop;
\r
120 //GaborIMG[0].draw();
\r
124 //if (!stop) Display.flip();
\r
132 public void psychlops_main()
\r
135 Canvas display = new Canvas(Canvas.window);
\r
137 PositionalBiasisInMovingGabor();
\r
151 namespace PsychlopsSilverlightApp
\r
154 public class PsychlopsMain
\r
157 Psychlops.Canvas cnvs;
\r
159 double x, y, z, t, p, temp, xx, yy;
\r
161 //Set Target Initial Value
\r
162 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
164 //Set Background Initial Value
\r
165 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
166 Psychlops.Widgets.Slider thetaSpeed, DotNumber;
\r
171 public void psychlops_main()
\r
174 cnvs = new Canvas(500, 500);
\r
176 // Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);
\r
177 // img = new Image("Resources/logo.png");
\r
179 Interval rng = new Interval();
\r
180 thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);
\r
181 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
183 //Declare background dots and target
\r
184 Rectangle[] BGDot = new Rectangle[2048];
\r
185 for (int i = 0; i < 2048; i++)
\r
187 BGDot[i]=new Rectangle();
\r
189 Rectangle[] Target= new Rectangle[10];
\r
190 for(int i=0; i<10; i++){
\r
191 Target[i]=new Rectangle();
\r
196 //Declare Matrix to keep back ground dots' coordinate value
\r
197 double[] DotX=new double[2048];
\r
198 double[] DotY = new double[2048];
\r
200 AppState.statusBar = "dvcscxz";
\r
201 //Set Independent variables to manipulate
\r
204 //Initialize positions of background dots
\r
205 for(int i=0; i<2048; i++){
\r
206 t=2.0*Math.PI*Math.random(1.0);
\r
207 p=2.0*Math.PI*Math.random(1.0);
\r
211 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
212 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
213 BGDot[i].set(BGSize, BGSize);
\r
214 BGDot[i].centering().shift(x,y);
\r
217 //Initialize positions of targets
\r
218 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
222 //Main stimulus loop
\r
224 //Clear the main window
\r
228 temp=Axis/360*2*Math.PI;
\r
229 COS=Math.cos(temp);
\r
230 SIN=Math.sin(temp);
\r
232 //Calculate positions of background dots and set them
\r
233 for(int i=0; i<DotNumber; i++){
\r
234 //Calculate in polar coordinate
\r
235 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
238 //Save current position
\r
241 //Convert to Decartes coordinate
\r
242 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
243 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
244 z=BGRadii*Math.sin(p);
\r
248 //Set Dotsize and Draw them
\r
249 BGDot[i].set(BGSize, BGSize);
\r
250 BGDot[i].centering().shift(xx,yy);
\r
251 BGDot[i].draw( Color.blue );
\r
254 //Calculate positions of targets and set them
\r
255 temp=Rotate*2*Math.PI/360.0;
\r
256 for (int i = 0; i < 5; i++)
\r
258 t = 2.0 * Math.PI/TargetNumber;
\r
259 x = TargetEcce*Math.cos(i*t+temp);
\r
260 y = TargetEcce*Math.sin(i*t+temp);
\r
261 Target[i].centering().shift(x,y);
\r
262 Target[i].fill = Color.yellow;
\r
266 // img.centering(Mouse.position).draw();
\r
268 cnvs.var(Mouse.position.x, 100, 100);
\r
269 cnvs.var(Mouse.position.y, 100, 140);
\r
271 //Reflect drawing at the next frame;
\r
288 namespace PsychlopsSilverlight4test
\r
291 public class PsychlopsMain
\r
294 Psychlops.Canvas cnvs;
\r
296 double x, y, z, t, p, temp, xx, yy;
\r
298 //Set Target Initial Value
\r
299 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
301 //Set Background Initial Value
\r
302 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
303 Psychlops.Widgets.Slider thetaSpeed, DotNumber;
\r
308 public void psychlops_main()
\r
310 cnvs = new Canvas(500, 500);
\r
312 Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);
\r
315 img = new Image("Resources/logo.png");
\r
317 Interval rng = new Interval();
\r
318 thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);
\r
319 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
321 //Declare background dots and target
\r
322 Rectangle[] BGDot = new Rectangle[2048];
\r
323 for(int i=0; i<2048; i++){
\r
324 BGDot[i]=new Rectangle();
\r
326 Rectangle[] Target= new Rectangle[10];
\r
327 for(int i=0; i<10; i++){
\r
328 Target[i]=new Rectangle();
\r
332 //Declare Matrix to keep back ground dots' coordinate value
\r
333 double[] DotX=new double[2048];
\r
334 double[] DotY = new double[2048];
\r
337 //Set Independent variables to manipulate
\r
340 //Initialize positions of background dots
\r
341 for(int i=0; i<2048; i++){
\r
342 t=2.0*Math.PI*Math.random(1.0);
\r
343 p=2.0*Math.PI*Math.random(1.0);
\r
347 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
348 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
349 BGDot[i].set(BGSize, BGSize);
\r
350 BGDot[i].centering().shift(x,y);
\r
353 //Initialize positions of targets
\r
354 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
358 //Main stimulus loop
\r
360 //Clear the main window
\r
364 temp=Axis/360*2*Math.PI;
\r
365 COS=Math.cos(temp);
\r
366 SIN=Math.sin(temp);
\r
368 //Calculate positions of background dots and set them
\r
369 for(int i=0; i<DotNumber; i++){
\r
370 //Calculate in polar coordinate
\r
371 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
374 //Save current position
\r
377 //Convert to Decartes coordinate
\r
378 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
379 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
380 z=BGRadii*Math.sin(p);
\r
384 //Set Dotsize and Draw them
\r
385 BGDot[i].set(BGSize, BGSize);
\r
386 BGDot[i].centering().shift(xx,yy);
\r
387 BGDot[i].draw( Color.blue );
\r
390 //Calculate positions of targets and set them
\r
391 temp=Rotate*2*Math.PI/360.0;
\r
392 for (int i = 0; i < 5; i++)
\r
394 t = 2.0 * Math.PI/TargetNumber;
\r
395 x = TargetEcce*Math.cos(i*t+temp);
\r
396 y = TargetEcce*Math.sin(i*t+temp);
\r
397 Target[i].centering().shift(x,y);
\r
398 Target[i].fill = Color.yellow;
\r
402 img.centering(Mouse.position).draw();
\r
404 cnvs.var(Mouse.position.x, 100, 100);
\r
405 cnvs.var(Mouse.position.y, 100, 140);
\r
407 //Reflect drawing at the next frame;
\r
419 namespace PsychlopsSilverlight4test
\r
421 public class PsychlopsMain
\r
423 public void psychlops_main()
\r
425 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
426 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
427 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
428 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
429 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
430 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
431 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
432 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
434 Canvas window = new Canvas(300, 300);
\r
436 var figure_r = new Rectangle();
\r
437 var figure_e = new Ellipse();
\r
438 Shape figure = figure_r;
\r
440 while (!Keyboard.esc.pushed())
\r
442 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
444 figure_r.set(size_x, size_y);
\r
449 figure_e.set(size_x, size_y);
\r
452 figure.fill = new Color(color_r, color_g, color_b);
\r
454 window.clear(Color.black);
\r
455 figure.centering().shift(shift_x, shift_y).draw();
\r
469 namespace Psychlops
\r
472 public class RandomDots
\r
475 public Point[] cood;
\r
476 public RandomDots()
\r
478 cood = new Point[250];
\r
479 dot = new Rectangle(5, 5);
\r
483 dot.fill = Color.white;
\r
484 foreach (Point p in cood)
\r
486 dot.centering(p).draw();
\r
495 namespace PsychlopsSilverlight4test
\r
498 public class PsychlopsMain
\r
511 public void psychlops_main()
\r
513 cnvs = new Canvas(500, 500);
\r
515 img = new Image(isize * 2, isize * 2);
\r
516 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
519 fixation = new Ellipse(10, 10);
\r
520 fixation.fill = Color.red;
\r
521 //var poly = new Rectangle(100, 100);
\r
522 var poly = new Letters("日本語");
\r
523 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
524 //var poly = new Ellipse(100, 100);
\r
525 //var poly = new Line(0,0,100, 0);
\r
526 poly.fill = Color.red;
\r
527 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
530 var rng = new Interval();
\r
531 var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);
\r
533 dots = new RandomDots();
\r
541 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
542 col.set(Math.random(1.0));
\r
544 /*if (frames % 2 == 0)
\r
546 fixation.centering().shift(100, 100);
\r
547 fixation.draw(new Stroke(Color.blue, 3));
\r
550 fixation.centering().shift(slider, 0);
\r
551 fixation.draw(Color.red);
\r
553 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
554 //Figures.drawGaussian(ref img, 20, 1);
\r
555 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
556 //img.centering(Mouse.position);
\r
558 g.centering(Mouse.position).draw();
\r
561 shape.centering(Mouse.position).shift(100, 0);
\r
563 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
565 cnvs.var(frames, 0, 20);
\r
566 //slider.value = frames / 100.0;
\r
568 /*if (frames % 2 != 0)
\r
570 fixation.shift(100, 100);
\r
571 fixation.draw(new Stroke(Color.green, 3));
\r
574 for (int i = 0; i < dots.cood.Length; i++)
\r
576 dots.cood[i].set(Math.random(500), Math.random(500));
\r
578 cnvs.var((double)slider, 200, 200);
\r
593 namespace PsychlopsSilverlight4test
\r
596 public class PsychlopsMain
\r
602 public void psychlops_main()
\r
605 cnvs = new Canvas(500, 500);
\r
606 rect = new Rectangle[n];
\r
607 for (int i = 0; i < n; i++)
\r
609 rect[i] = new Rectangle(10, 10);
\r
610 rect[i].fill = Color.red;
\r
612 Interval rng = new Interval();
\r
613 var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);
\r
618 for (int i = 0; i < n; i++)
\r
620 rect[i].centering().shift(slider * i*3, i*3).draw();
\r
633 namespace PsychlopsSilverlight4test
\r
635 public class PsychlopsMain
\r
637 public void psychlops_main()
\r
639 Canvas window = new Canvas(300, 300);
\r
641 var figure_r = new Rectangle();
\r
642 var figure_e = new Ellipse();
\r
643 figure_r.set(100,100).centering().shift(0, 0);
\r
644 figure_e.set(100,100).centering().shift(0, 0);
\r
646 while (!Keyboard.esc.pushed())
\r
648 figure_r.fill = new Color(0, 0, 1);
\r
649 figure_r.centering(new Point(100,100)).draw();
\r
650 figure_e.fill = new Color(1, 0, 0);
\r
651 figure_e.centering(new Point(100, 100)).draw();
\r
665 namespace PsychlopsSilverlight4test
\r
667 public class PsychlopsMain
\r
669 public void psychlops_main()
\r
671 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
672 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
673 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
674 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
675 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
676 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
678 Canvas window = new Canvas(300, 300);
\r
680 var figure_r = new Rectangle();
\r
681 var figure_e = new Ellipse();
\r
682 figure_r.centering().shift(0, 0);
\r
683 figure_e.centering().shift(0, 0);
\r
686 int direction = 1, motion_dir = 1;
\r
688 while (!Keyboard.esc.pushed())
\r
692 if (frame % 30 == 0)
\r
694 direction = direction * -1;
\r
698 if (frame % 90 == 0)
\r
703 figure_r.resize(figure_r.getWidth() + direction * 1, figure_r.getHeight() + direction * 1);
\r
704 figure_r.shift(motion_dir * 1, 0);
\r
705 figure_r.fill = new Color(color_r, color_g, color_b);
\r
707 figure_e.resize(figure_e.getWidth() + direction * 1, figure_e.getHeight() + direction * 1);
\r
708 figure_e.shift(motion_dir * 1, 0);
\r
709 figure_e.fill = new Color(color_r, color_g, color_b);
\r
711 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
736 namespace PsychlopsSilverlight4test
\r
738 public class PsychlopsMain
\r
740 public void psychlops_main()
\r
742 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
743 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
744 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
745 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
746 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
747 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
748 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
749 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
751 Canvas window = new Canvas(300, 300);
\r
753 var figure_r = new Rectangle();
\r
754 var figure_e = new Ellipse();
\r
755 Shape figure = figure_r;
\r
757 while (!Keyboard.esc.pushed())
\r
759 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
761 figure_r.set(size_x, size_y);
\r
766 figure_e.set(size_x, size_y);
\r
769 figure.fill = new Color(color_r, color_g, color_b);
\r
771 window.clear(Color.black);
\r
772 figure.centering().shift(shift_x, shift_y).draw();
\r
785 namespace Psychlops
\r
788 public class RandomDots
\r
791 public Point[] cood;
\r
792 public RandomDots()
\r
794 cood = new Point[250];
\r
795 dot = new Rectangle(5, 5);
\r
799 dot.fill = Color.white;
\r
800 foreach (Point p in cood)
\r
802 dot.centering(p).draw();
\r
810 namespace PsychlopsSilverlight4test
\r
813 public class PsychlopsMain
\r
817 Rectangle fixation;
\r
825 public void psychlops_main()
\r
827 cnvs = new Canvas(500, 500);
\r
828 img = new Image(isize * 2, isize * 2);
\r
829 fixation = new Rectangle(10, 10);
\r
830 fixation.fill = Color.red;
\r
831 //var poly = new Rectangle(100, 100);
\r
832 var poly = new Letters("日本語");
\r
833 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
834 //var poly = new Ellipse(100, 100);
\r
835 //var poly = new Line(0,0,100, 0);
\r
836 poly.fill = Color.red;
\r
837 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
840 var rng = new Interval();
\r
841 var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);
\r
843 dots = new RandomDots();
\r
849 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
850 col.set(Math.random(1.0));
\r
852 fixation.centering();
\r
853 fixation.draw(Color.red);
\r
855 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
856 //Figures.drawGaussian(ref img, 20, 1);
\r
857 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
858 img.centering(Mouse.position);
\r
861 shape.centering(Mouse.position).shift(100,0);
\r
863 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
865 cnvs.var(frames, 20, 20);
\r
866 slider.value = frames/100.0;
\r
868 fixation.shift(100,100);
\r
869 fixation.draw(new Stroke(Color.blue, 3));
\r
871 for (int i=0; i<dots.cood.Length; i++)
\r
873 dots.cood[i].set(Math.random(500), Math.random(500));
\r