3 namespace PsychlopsSilverlight4test
\r
6 public class PsychlopsMain
\r
12 double x, y, z, t, p, temp, xx, yy;
\r
14 //Set Target Initial Value
\r
15 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
17 //Set Background Initial Value
\r
18 double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
19 Psychlops.Widgets.Slider DotNumberS;
\r
21 public void psychlops_main()
\r
23 throw new System.Exception("Speed");
\r
24 //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500));
\r
25 //Independent ind = new Independent();
\r
27 cnvs = new Canvas(500, 500);
\r
29 //Image img = new Image(20, 20);
\r
30 //img.field(delegate(int x, int y) { return new Color(Math.sin(x + y)); });
\r
32 for (int x = 0; x < 20; x++)
\r
34 for (int y = 0; y < 20; y++)
\r
36 // img.pix(x, y, new Color(Math.sin(x + y)));
\r
42 //Declare background dots and target
\r
43 Rectangle[] BGDot = new Rectangle[2048];
\r
44 for(int i=0; i<2048; i++){
\r
45 BGDot[i]=new Rectangle();
\r
47 Rectangle[] Target= new Rectangle[10];
\r
48 for(int i=0; i<10; i++){
\r
49 Target[i]=new Rectangle();
\r
53 //Declare Matrix to keep back ground dots' coordinate value
\r
54 double[] DotX=new double[2048];
\r
55 double[] DotY = new double[2048];
\r
58 //Set Independent variables to manipulate
\r
61 //Initialize positions of background dots
\r
62 for(int i=0; i<2048; i++){
\r
63 t=2.0*Math.PI*Math.random(1.0);
\r
64 p=2.0*Math.PI*Math.random(1.0);
\r
68 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
69 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
70 BGDot[i].set(BGSize, BGSize);
\r
71 BGDot[i].centering().shift(x,y);
\r
74 //Initialize positions of targets
\r
75 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
79 //Main stimulus loop
\r
81 //Clear the main window
\r
82 cnvs.clear(Color.black);
\r
85 temp=Axis/360*2*Math.PI;
\r
89 //Calculate positions of background dots and set them
\r
90 for(int i=0; i<DotNumber; i++){
\r
91 //Calculate in polar coordinate
\r
92 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
95 //Save current position
\r
98 //Convert to Decartes coordinate
\r
99 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
100 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
101 z=BGRadii*Math.sin(p);
\r
105 //Set Dotsize and Draw them
\r
106 BGDot[i].set(BGSize, BGSize);
\r
107 BGDot[i].centering().shift(xx,yy);
\r
108 BGDot[i].draw( Color.blue);
\r
111 //Calculate positions of targets and set them
\r
112 temp=Rotate*2*Math.PI/360.0;
\r
113 cnvs.msg(TargetNumber.ToString(), 0, 30);
\r
114 for (int i = 0; i < 5; i++)
\r
116 cnvs.msg(i.ToString(), 50+50*i, 30);
\r
117 t = 2.0 * Math.PI/TargetNumber;
\r
118 x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp);
\r
119 y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp);
\r
120 Target[i].centering().shift(x,y);
\r
121 Target[i].fill = Color.yellow;
\r
125 //img.centering().draw();
\r
126 //Reflect drawing at the next frame;
\r
141 namespace PsychlopsSilverlight4test
\r
143 public class PsychlopsMain
\r
145 public void psychlops_main()
\r
147 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
148 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
149 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
150 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
151 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
152 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
153 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
154 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
156 Canvas window = new Canvas(300, 300);
\r
158 var figure_r = new Rectangle();
\r
159 var figure_e = new Ellipse();
\r
160 Shape figure = figure_r;
\r
162 while (!Keyboard.esc.pushed())
\r
164 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
166 figure_r.set(size_x, size_y);
\r
171 figure_e.set(size_x, size_y);
\r
174 figure.fill = new Color(color_r, color_g, color_b);
\r
176 window.clear(Color.black);
\r
177 figure.centering().shift(shift_x, shift_y).draw();
\r
192 namespace Psychlops
\r
195 public class RandomDots
\r
198 public Point[] cood;
\r
199 public RandomDots()
\r
201 cood = new Point[250];
\r
202 dot = new Rectangle(5, 5);
\r
206 dot.fill = Color.white;
\r
207 foreach (Point p in cood)
\r
209 dot.centering(p).draw();
\r
218 namespace PsychlopsSilverlight4test
\r
221 public class PsychlopsMain
\r
225 Rectangle fixation;
\r
233 public void psychlops_main()
\r
235 cnvs = new Canvas(500, 500);
\r
236 img = new Image(isize * 2, isize * 2);
\r
237 fixation = new Rectangle(10, 10);
\r
238 fixation.fill = Color.red;
\r
239 //var poly = new Rectangle(100, 100);
\r
240 var poly = new Letters("日本語");
\r
241 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
242 //var poly = new Ellipse(100, 100);
\r
243 //var poly = new Line(0,0,100, 0);
\r
244 poly.fill = Color.red;
\r
245 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
248 var rng = new Interval();
\r
249 var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);
\r
251 dots = new RandomDots();
\r
258 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
259 col.set(Math.random(1.0));
\r
261 fixation.centering();
\r
262 fixation.draw(Color.red);
\r
264 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
265 //Figures.drawGaussian(ref img, 20, 1);
\r
266 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
267 img.centering(Mouse.position);
\r
270 shape.centering(Mouse.position).shift(100, 0);
\r
272 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
274 cnvs.var(frames, 20, 20);
\r
275 slider.value = frames / 100.0;
\r
277 fixation.shift(100, 100);
\r
278 fixation.draw(new Stroke(Color.blue, 3));
\r
280 for (int i = 0; i < dots.cood.Length; i++)
\r
282 dots.cood[i].set(Math.random(500), Math.random(500));
\r