5 namespace PsychlopsSilverlight4test
\r
9 public class PsychlopsMain
\r
15 double x, y, z, t, p, temp, xx, yy;
\r
17 //Set Target Initial Value
\r
18 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;
\r
20 //Set Background Initial Value
\r
21 double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;
\r
22 Psychlops.Widgets.Slider DotNumberS;
\r
24 public void psychlops_main()
\r
26 throw new System.Exception("Speed");
\r
27 //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500));
\r
28 //Independent ind = new Independent();
\r
30 cnvs = new Canvas(500, 500);
\r
32 //Image img = new Image(20, 20);
\r
33 //img.field(delegate(int x, int y) { return new Color(Math.sin(x + y)); });
\r
35 for (int x = 0; x < 20; x++)
\r
37 for (int y = 0; y < 20; y++)
\r
39 // img.pix(x, y, new Color(Math.sin(x + y)));
\r
44 //Declare background dots and target
\r
45 Rectangle[] BGDot = new Rectangle[2048];
\r
46 for(int i=0; i<2048; i++){
\r
47 BGDot[i]=new Rectangle();
\r
49 Rectangle[] Target= new Rectangle[10];
\r
50 for(int i=0; i<10; i++){
\r
51 Target[i]=new Rectangle();
\r
55 //Declare Matrix to keep back ground dots' coordinate value
\r
56 double[] DotX=new double[2048];
\r
57 double[] DotY = new double[2048];
\r
60 //Set Independent variables to manipulate
\r
63 //Initialize positions of background dots
\r
64 for(int i=0; i<2048; i++){
\r
65 t=2.0*Math.PI*Math.random(1.0);
\r
66 p=2.0*Math.PI*Math.random(1.0);
\r
70 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
71 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
72 BGDot[i].set(BGSize, BGSize);
\r
73 BGDot[i].centering().shift(x,y);
\r
76 //Initialize positions of targets
\r
77 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
81 //Main stimulus loop
\r
83 //Clear the main window
\r
84 cnvs.clear(Color.black);
\r
87 temp=Axis/360*2*Math.PI;
\r
91 //Calculate positions of background dots and set them
\r
92 for(int i=0; i<DotNumber; i++){
\r
93 //Calculate in polar coordinate
\r
94 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
97 //Save current position
\r
100 //Convert to Decartes coordinate
\r
101 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
102 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
103 z=BGRadii*Math.sin(p);
\r
107 //Set Dotsize and Draw them
\r
108 BGDot[i].set(BGSize, BGSize);
\r
109 BGDot[i].centering().shift(xx,yy);
\r
110 BGDot[i].draw( Color.blue);
\r
113 //Calculate positions of targets and set them
\r
114 temp=Rotate*2*Math.PI/360.0;
\r
115 cnvs.msg(TargetNumber.ToString(), 0, 30);
\r
116 for (int i = 0; i < 5; i++)
\r
118 cnvs.msg(i.ToString(), 50+50*i, 30);
\r
119 t = 2.0 * Math.PI/TargetNumber;
\r
120 x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp);
\r
121 y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp);
\r
122 Target[i].centering().shift(x,y);
\r
123 Target[i].fill = Color.yellow;
\r
127 //img.centering().draw();
\r
128 //Reflect drawing at the next frame;
\r
143 namespace PsychlopsSilverlight4test
\r
145 public class PsychlopsMain
\r
147 public void psychlops_main()
\r
149 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
150 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
151 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
152 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
153 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
154 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
155 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
156 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
158 Canvas window = new Canvas(300, 300);
\r
160 var figure_r = new Rectangle();
\r
161 var figure_e = new Ellipse();
\r
162 Shape figure = figure_r;
\r
164 while (!Keyboard.esc.pushed())
\r
166 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
168 figure_r.set(size_x, size_y);
\r
173 figure_e.set(size_x, size_y);
\r
176 figure.fill = new Color(color_r, color_g, color_b);
\r
178 window.clear(Color.black);
\r
179 figure.centering().shift(shift_x, shift_y).draw();
\r
194 namespace Psychlops
\r
197 public class RandomDots
\r
200 public Point[] cood;
\r
201 public RandomDots()
\r
203 cood = new Point[250];
\r
204 dot = new Rectangle(5, 5);
\r
208 dot.fill = Color.white;
\r
209 foreach (Point p in cood)
\r
211 dot.centering(p).draw();
\r
221 namespace PsychlopsSilverlight4test
\r
224 public class PsychlopsMain
\r
228 Rectangle fixation;
\r
236 public void psychlops_main()
\r
238 cnvs = new Canvas(500, 500);
\r
239 img = new Image(isize * 2, isize * 2);
\r
240 fixation = new Rectangle(10, 10);
\r
241 fixation.fill = Color.red;
\r
242 //var poly = new Rectangle(100, 100);
\r
243 var poly = new Letters("日本語");
\r
244 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
245 //var poly = new Ellipse(100, 100);
\r
246 //var poly = new Line(0,0,100, 0);
\r
247 poly.fill = Color.red;
\r
248 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
251 var rng = new Interval();
\r
252 var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);
\r
254 dots = new RandomDots();
\r
261 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
262 col.set(Math.random(1.0));
\r
264 fixation.centering();
\r
265 fixation.draw(Color.red);
\r
267 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
268 //Figures.drawGaussian(ref img, 20, 1);
\r
269 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
270 img.centering(Mouse.position);
\r
273 shape.centering(Mouse.position).shift(100, 0);
\r
275 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
277 cnvs.var(frames, 20, 20);
\r
278 slider.value = frames / 100.0;
\r
280 fixation.shift(100, 100);
\r
281 fixation.draw(new Stroke(Color.blue, 3));
\r
283 for (int i = 0; i < dots.cood.Length; i++)
\r
285 dots.cood[i].set(Math.random(500), Math.random(500));
\r