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
27 Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);
\r
30 img = new Image("Resources/logo.png");
\r
32 Interval rng = new Interval();
\r
33 thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);
\r
34 DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);
\r
36 //Declare background dots and target
\r
37 Rectangle[] BGDot = new Rectangle[2048];
\r
38 for(int i=0; i<2048; i++){
\r
39 BGDot[i]=new Rectangle();
\r
41 Rectangle[] Target= new Rectangle[10];
\r
42 for(int i=0; i<10; i++){
\r
43 Target[i]=new Rectangle();
\r
47 //Declare Matrix to keep back ground dots' coordinate value
\r
48 double[] DotX=new double[2048];
\r
49 double[] DotY = new double[2048];
\r
52 //Set Independent variables to manipulate
\r
55 //Initialize positions of background dots
\r
56 for(int i=0; i<2048; i++){
\r
57 t=2.0*Math.PI*Math.random(1.0);
\r
58 p=2.0*Math.PI*Math.random(1.0);
\r
62 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
63 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
64 BGDot[i].set(BGSize, BGSize);
\r
65 BGDot[i].centering().shift(x,y);
\r
68 //Initialize positions of targets
\r
69 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
73 //Main stimulus loop
\r
75 //Clear the main window
\r
79 temp=Axis/360*2*Math.PI;
\r
83 //Calculate positions of background dots and set them
\r
84 for(int i=0; i<DotNumber; i++){
\r
85 //Calculate in polar coordinate
\r
86 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
89 //Save current position
\r
92 //Convert to Decartes coordinate
\r
93 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
94 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
95 z=BGRadii*Math.sin(p);
\r
99 //Set Dotsize and Draw them
\r
100 BGDot[i].set(BGSize, BGSize);
\r
101 BGDot[i].centering().shift(xx,yy);
\r
102 BGDot[i].draw( Color.blue );
\r
105 //Calculate positions of targets and set them
\r
106 temp=Rotate*2*Math.PI/360.0;
\r
107 for (int i = 0; i < 5; i++)
\r
109 t = 2.0 * Math.PI/TargetNumber;
\r
110 x = TargetEcce*Math.cos(i*t+temp);
\r
111 y = TargetEcce*Math.sin(i*t+temp);
\r
112 Target[i].centering().shift(x,y);
\r
113 Target[i].fill = Color.yellow;
\r
117 img.centering(Mouse.position).draw();
\r
119 cnvs.var(Mouse.position.x, 100, 100);
\r
120 cnvs.var(Mouse.position.y, 100, 140);
\r
122 //Reflect drawing at the next frame;
\r
134 namespace PsychlopsSilverlight4test
\r
136 public class PsychlopsMain
\r
138 public void psychlops_main()
\r
140 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
141 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
142 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
143 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
144 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
145 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
146 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
147 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
149 Canvas window = new Canvas(300, 300);
\r
151 var figure_r = new Rectangle();
\r
152 var figure_e = new Ellipse();
\r
153 Shape figure = figure_r;
\r
155 while (!Keyboard.esc.pushed())
\r
157 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
159 figure_r.set(size_x, size_y);
\r
164 figure_e.set(size_x, size_y);
\r
167 figure.fill = new Color(color_r, color_g, color_b);
\r
169 window.clear(Color.black);
\r
170 figure.centering().shift(shift_x, shift_y).draw();
\r
184 namespace Psychlops
\r
187 public class RandomDots
\r
190 public Point[] cood;
\r
191 public RandomDots()
\r
193 cood = new Point[250];
\r
194 dot = new Rectangle(5, 5);
\r
198 dot.fill = Color.white;
\r
199 foreach (Point p in cood)
\r
201 dot.centering(p).draw();
\r
210 namespace PsychlopsSilverlight4test
\r
213 public class PsychlopsMain
\r
226 public void psychlops_main()
\r
228 cnvs = new Canvas(500, 500);
\r
230 img = new Image(isize * 2, isize * 2);
\r
231 Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
234 fixation = new Ellipse(10, 10);
\r
235 fixation.fill = Color.red;
\r
236 //var poly = new Rectangle(100, 100);
\r
237 var poly = new Letters("日本語");
\r
238 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
239 //var poly = new Ellipse(100, 100);
\r
240 //var poly = new Line(0,0,100, 0);
\r
241 poly.fill = Color.red;
\r
242 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
245 var rng = new Interval();
\r
246 var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);
\r
248 dots = new RandomDots();
\r
256 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
257 col.set(Math.random(1.0));
\r
259 /*if (frames % 2 == 0)
\r
261 fixation.centering().shift(100, 100);
\r
262 fixation.draw(new Stroke(Color.blue, 3));
\r
265 fixation.centering().shift(slider, 0);
\r
266 fixation.draw(Color.red);
\r
268 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
269 //Figures.drawGaussian(ref img, 20, 1);
\r
270 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
271 //img.centering(Mouse.position);
\r
273 g.centering(Mouse.position).draw();
\r
276 shape.centering(Mouse.position).shift(100, 0);
\r
278 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
280 cnvs.var(frames, 0, 20);
\r
281 //slider.value = frames / 100.0;
\r
283 /*if (frames % 2 != 0)
\r
285 fixation.shift(100, 100);
\r
286 fixation.draw(new Stroke(Color.green, 3));
\r
289 for (int i = 0; i < dots.cood.Length; i++)
\r
291 dots.cood[i].set(Math.random(500), Math.random(500));
\r
293 cnvs.var((double)slider, 200, 200);
\r
308 namespace PsychlopsSilverlight4test
\r
311 public class PsychlopsMain
\r
317 public void psychlops_main()
\r
320 cnvs = new Canvas(500, 500);
\r
321 rect = new Rectangle[n];
\r
322 for (int i = 0; i < n; i++)
\r
324 rect[i] = new Rectangle(10, 10);
\r
325 rect[i].fill = Color.red;
\r
327 Interval rng = new Interval();
\r
328 var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);
\r
333 for (int i = 0; i < n; i++)
\r
335 rect[i].centering().shift(slider * i*3, i*3).draw();
\r