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 DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
19 public void psychlops_main()
\r
21 cnvs = new Canvas(500, 500);
\r
23 //Declare background dots and target
\r
24 Rectangle[] BGDot = new Rectangle[2048];
\r
25 for(int i=0; i<2048; i++){
\r
26 BGDot[i]=new Rectangle();
\r
28 Rectangle[] Target= new Rectangle[10];
\r
29 for(int i=0; i<10; i++){
\r
30 Target[i]=new Rectangle();
\r
34 //Declare Matrix to keep back ground dots' coordinate value
\r
35 double[] DotX=new double[2048];
\r
36 double[] DotY = new double[2048];
\r
39 //Set Independent variables to manipulate
\r
42 //Initialize positions of background dots
\r
43 for(int i=0; i<2048; i++){
\r
44 t=2.0*Math.PI*Math.random(1.0);
\r
45 p=2.0*Math.PI*Math.random(1.0);
\r
49 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
50 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
51 BGDot[i].set(BGSize, BGSize);
\r
52 BGDot[i].centering().shift(x,y);
\r
55 //Initialize positions of targets
\r
56 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
60 //Main stimulus loop
\r
62 //Clear the main window
\r
63 cnvs.clear(Color.green);
\r
66 temp=Axis/360*2*Math.PI;
\r
70 //Calculate positions of background dots and set them
\r
71 for(int i=0; i<DotNumber; i++){
\r
72 //Calculate in polar coordinate
\r
73 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
76 //Save current position
\r
79 //Convert to Decartes coordinate
\r
80 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
81 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
82 z=BGRadii*Math.sin(p);
\r
86 //Set Dotsize and Draw them
\r
87 BGDot[i].set(BGSize, BGSize);
\r
88 BGDot[i].centering().shift(xx,yy);
\r
89 BGDot[i].draw( Color.blue );
\r
92 //Calculate positions of targets and set them
\r
93 temp=Rotate*2*Math.PI/360.0;
\r
94 for (int i = 0; i < 5; i++)
\r
96 t = 2.0 * Math.PI/TargetNumber;
\r
97 x = TargetEcce*Math.cos(i*t+temp);
\r
98 y = TargetEcce*Math.sin(i*t+temp);
\r
99 Target[i].centering().shift(x,y);
\r
100 Target[i].fill = Color.yellow;
\r
104 //Reflect drawing at the next frame;
\r
115 namespace PsychlopsSilverlight4test
\r
117 public class PsychlopsMain
\r
119 public void psychlops_main()
\r
121 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
122 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
123 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
124 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
125 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
126 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
127 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
128 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
130 Canvas window = new Canvas(300, 300);
\r
132 var figure_r = new Rectangle();
\r
133 var figure_e = new Ellipse();
\r
134 Shape figure = figure_r;
\r
136 while (!Keyboard.esc.pushed())
\r
138 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
140 figure_r.set(size_x, size_y);
\r
145 figure_e.set(size_x, size_y);
\r
148 figure.fill = new Color(color_r, color_g, color_b);
\r
150 window.clear(Color.black);
\r
151 figure.centering().shift(shift_x, shift_y).draw();
\r
165 namespace Psychlops
\r
168 public class RandomDots
\r
171 public Point[] cood;
\r
172 public RandomDots()
\r
174 cood = new Point[250];
\r
175 dot = new Rectangle(5, 5);
\r
179 dot.fill = Color.white;
\r
180 foreach (Point p in cood)
\r
182 dot.centering(p).draw();
\r
191 namespace PsychlopsSilverlight4test
\r
194 public class PsychlopsMain
\r
207 public void psychlops_main()
\r
209 cnvs = new Canvas(500, 500);
\r
211 img = new Image(isize * 2, isize * 2);
\r
212 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
215 fixation = new Ellipse(10, 10);
\r
216 fixation.fill = Color.red;
\r
217 //var poly = new Rectangle(100, 100);
\r
218 var poly = new Letters("日本語");
\r
219 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
220 //var poly = new Ellipse(100, 100);
\r
221 //var poly = new Line(0,0,100, 0);
\r
222 poly.fill = Color.red;
\r
223 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
226 var rng = new Interval();
\r
227 var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);
\r
229 dots = new RandomDots();
\r
237 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
238 col.set(Math.random(1.0));
\r
240 /*if (frames % 2 == 0)
\r
242 fixation.centering().shift(100, 100);
\r
243 fixation.draw(new Stroke(Color.blue, 3));
\r
246 fixation.centering();
\r
247 fixation.draw(Color.red);
\r
249 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
250 //Figures.drawGaussian(ref img, 20, 1);
\r
251 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
252 img.centering(Mouse.position);
\r
254 //g.centering(Mouse.position).draw();
\r
257 shape.centering(Mouse.position).shift(100, 0);
\r
259 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
261 cnvs.var(frames, 0, 20);
\r
262 slider.value = frames / 100.0;
\r
264 /*if (frames % 2 != 0)
\r
266 fixation.shift(100, 100);
\r
267 fixation.draw(new Stroke(Color.green, 3));
\r
270 for (int i = 0; i < dots.cood.Length; i++)
\r
272 dots.cood[i].set(Math.random(500), Math.random(500));
\r