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 //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500));
\r
27 //Independent ind = new Independent();
\r
29 cnvs = new Canvas(500, 500);
\r
31 Image img = new Image(100, 100);
\r
32 img.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); });
\r
33 Image img2 = new Image(100, 100);
\r
34 img2.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); });
\r
36 for (int x = 0; x < 20; x++)
\r
38 for (int y = 0; y < 20; y++)
\r
40 // img.pix(x, y, new Color(Math.sin(x + y)));
\r
45 //Declare background dots and target
\r
46 Rectangle[] BGDot = new Rectangle[2048];
\r
47 for(int i=0; i<2048; i++){
\r
48 BGDot[i]=new Rectangle();
\r
50 Rectangle[] Target= new Rectangle[10];
\r
51 for(int i=0; i<10; i++){
\r
52 Target[i]=new Rectangle();
\r
56 //Declare Matrix to keep back ground dots' coordinate value
\r
57 double[] DotX=new double[2048];
\r
58 double[] DotY = new double[2048];
\r
61 //Set Independent variables to manipulate
\r
64 //Initialize positions of background dots
\r
65 for(int i=0; i<2048; i++){
\r
66 t=2.0*Math.PI*Math.random(1.0);
\r
67 p=2.0*Math.PI*Math.random(1.0);
\r
71 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
72 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
73 BGDot[i].set(BGSize, BGSize);
\r
74 BGDot[i].centering().shift(x,y);
\r
77 //Initialize positions of targets
\r
78 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);
\r
82 //Main stimulus loop
\r
84 //Clear the main window
\r
85 cnvs.clear(Color.green);
\r
88 temp=Axis/360*2*Math.PI;
\r
92 //Calculate positions of background dots and set them
\r
93 for(int i=0; i<DotNumber; i++){
\r
94 //Calculate in polar coordinate
\r
95 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;
\r
98 //Save current position
\r
101 //Convert to Decartes coordinate
\r
102 x=BGRadii*Math.cos(t)*Math.cos(p);
\r
103 y=BGRadii*Math.sin(t)*Math.cos(p);
\r
104 z=BGRadii*Math.sin(p);
\r
108 //Set Dotsize and Draw them
\r
109 BGDot[i].set(BGSize, BGSize);
\r
110 BGDot[i].centering().shift(xx,yy);
\r
111 BGDot[i].draw( Color.blue);
\r
114 //Calculate positions of targets and set them
\r
115 temp=Rotate*2*Math.PI/360.0;
\r
116 cnvs.msg(TargetNumber.ToString(), 0, 30);
\r
117 for (int i = 0; i < 5; i++)
\r
119 cnvs.msg(i.ToString(), 50+50*i, 30);
\r
120 t = 2.0 * Math.PI/TargetNumber;
\r
121 x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp);
\r
122 y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp);
\r
123 Target[i].centering().shift(x,y);
\r
124 Target[i].fill = Color.yellow;
\r
128 img.centering().draw();
\r
129 img2.centering().draw();
\r
130 //Reflect drawing at the next frame;
\r
142 namespace PsychlopsSilverlight4test
\r
144 public class PsychlopsMain
\r
146 public void psychlops_main()
\r
148 var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
149 var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
150 var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
151 var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");
\r
152 var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");
\r
153 var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
154 var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
155 var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
157 Canvas window = new Canvas(300, 300);
\r
159 var figure_r = new Rectangle();
\r
160 var figure_e = new Ellipse();
\r
161 Shape figure = figure_r;
\r
163 while (!Keyboard.esc.pushed())
\r
165 if (System.String.Compare(figure_type, "Rectangle") == 0)
\r
167 figure_r.set(size_x, size_y);
\r
172 figure_e.set(size_x, size_y);
\r
175 figure.fill = new Color(color_r, color_g, color_b);
\r
177 window.clear(Color.black);
\r
178 figure.centering().shift(shift_x, shift_y).draw();
\r
193 namespace Psychlops
\r
196 public class RandomDots
\r
199 public Point[] cood;
\r
200 public RandomDots()
\r
202 cood = new Point[250];
\r
203 dot = new Rectangle(5, 5);
\r
207 dot.fill = Color.white;
\r
208 foreach (Point p in cood)
\r
210 dot.centering(p).draw();
\r
220 namespace PsychlopsSilverlight4test
\r
223 public class PsychlopsMain
\r
227 Rectangle fixation;
\r
235 public void psychlops_main()
\r
237 cnvs = new Canvas(500, 500);
\r
238 img = new Image(isize * 2, isize * 2);
\r
239 fixation = new Rectangle(10, 10);
\r
240 fixation.fill = Color.red;
\r
241 //var poly = new Rectangle(100, 100);
\r
242 var poly = new Letters("日本語");
\r
243 //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);
\r
244 //var poly = new Ellipse(100, 100);
\r
245 //var poly = new Line(0,0,100, 0);
\r
246 poly.fill = Color.red;
\r
247 poly.stroke = new Stroke { color = Color.yellow, thick = 1 };
\r
250 var rng = new Interval();
\r
251 var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);
\r
253 dots = new RandomDots();
\r
260 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));
\r
261 col.set(Math.random(1.0));
\r
263 fixation.centering();
\r
264 fixation.draw(Color.red);
\r
266 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);
\r
267 //Figures.drawGaussian(ref img, 20, 1);
\r
268 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);
\r
269 img.centering(Mouse.position);
\r
272 shape.centering(Mouse.position).shift(100, 0);
\r
274 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);
\r
276 cnvs.var(frames, 20, 20);
\r
277 slider.value = frames / 100.0;
\r
279 fixation.shift(100, 100);
\r
280 fixation.draw(new Stroke(Color.blue, 3));
\r
282 for (int i = 0; i < dots.cood.Length; i++)
\r
284 dots.cood[i].set(Math.random(500), Math.random(500));
\r