OSDN Git Service

test
[psychlops/silverlight.git] / test5 / Store.cs
1 \r
2 /*\r
3 using Psychlops;\r
4 \r
5 namespace PsychlopsSilverlight4test\r
6 {\r
7 \r
8         public class PsychlopsMain\r
9         {\r
10                 void RectLuminance()\r
11                 {\r
12                         Canvas display = new Canvas(Canvas.window);\r
13                         Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
14                         Letters le = new Letters("Reload to restart");\r
15                         le.fill = Color.black;\r
16                         le.align = Letters.HorizontalAlign.center;\r
17 \r
18                         while (!Keyboard.esc.pushed())\r
19                         {\r
20                                 Display.clear(Color.white);\r
21                                 le.centering().shift(-200,-10).draw();\r
22                                 Display.flip();\r
23                         }\r
24 \r
25                 }\r
26 \r
27 \r
28                 public void psychlops_main()\r
29                 {\r
30                         RectLuminance();\r
31                 }\r
32 \r
33 \r
34         }\r
35 \r
36 }\r
37 \r
38 */\r
39 \r
40 \r
41 \r
42 /*\r
43 using Psychlops;\r
44 \r
45 namespace PsychlopsSilverlightApp\r
46 {\r
47 \r
48         public class PsychlopsMain\r
49         {\r
50 \r
51                 Psychlops.Widgets.Slider rect_size, freq, contrast;\r
52 \r
53                 void PositionalBiasisInMovingGabor()\r
54                 {\r
55                         double vel = 30.0;\r
56                         double StimWidth = 120;\r
57 \r
58                         Interval rng = new Interval();\r
59                         Psychlops.Widgets.Slider rect_size, freq, contrast;\r
60                         rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 120.0);\r
61                         freq = new Psychlops.Widgets.Slider("Sptial Frequency", 0.0 <= rng <= 1.0, 0.125);\r
62                         contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.1);\r
63 \r
64                         int IMAGES = (int)vel;\r
65 \r
66                         Image[] GaborIMG = new Image[200];\r
67                         for (int i = 0; i < 200; i++) GaborIMG[i] = new Image();\r
68 \r
69                         Color clrcol = new Color(), clrFP = new Color();\r
70                         Display.clear(0.5);\r
71                         clrcol.set(128.0 / 255.0);\r
72                         clrFP.set(128.0 / 255.0, 0.0, 0.0);\r
73 \r
74                         int phase = 0;\r
75                         double distance = rect_size;\r
76                         bool changed = true, stop = false;\r
77                         double prev_contrast = 0.0, prev_freq = 0.0, prev_size = 0.0;\r
78 \r
79                         while (!Keyboard.esc.pushed())\r
80                         {\r
81                                 Display.clear();\r
82 \r
83                                 if (prev_contrast != contrast || prev_freq != freq || prev_size != rect_size) changed = true;\r
84                                 prev_contrast = contrast;\r
85                                 prev_freq = freq;\r
86                                 prev_size = rect_size;\r
87                                 if (changed)\r
88                                 {\r
89                                         for (int i = 0; i < 2; i++)\r
90                                         {\r
91                                                 for (int j = 0; j < IMAGES; j++)\r
92                                                 {\r
93                                                         Figures.drawGabor(ref GaborIMG[i * IMAGES + j], rect_size / 8.0, freq, contrast, Math.PI * 0.5, 2.0 * Math.PI * j / IMAGES);\r
94                                                         distance = rect_size;\r
95                                                 }\r
96                                         }\r
97                                         changed = false;\r
98                                 }\r
99 \r
100                                 if (!stop)\r
101                                 {\r
102                                         Display.clear(127.0 / 255.0);\r
103                                         for (int i = 0; i < 3; i++)\r
104                                         {\r
105                                                 switch (i)\r
106                                                 {\r
107                                                         case 0:\r
108                                                                 GaborIMG[IMAGES - phase - 1].centering().shift(0, -distance);\r
109                                                                 GaborIMG[IMAGES - phase - 1].draw(); break;\r
110                                                         case 1:\r
111                                                                 GaborIMG[phase].centering().shift(0, 0);\r
112                                                                 GaborIMG[phase].draw(); break;\r
113                                                         case 2:\r
114                                                                 GaborIMG[IMAGES - phase - 1].centering().shift(0, +distance);\r
115                                                                 GaborIMG[IMAGES - phase - 1].draw(); break;\r
116                                                 }\r
117                                         }\r
118                                 }\r
119                                 if (Keyboard.spc.pushed()) stop = !stop;\r
120                                 //GaborIMG[0].draw();\r
121 \r
122                                 phase++;\r
123                                 phase %= IMAGES;\r
124                                 //if (!stop) Display.flip();\r
125                                 Display.flip();\r
126 \r
127                         }\r
128 \r
129                 }\r
130 \r
131 \r
132                 public void psychlops_main()\r
133                 {\r
134 \r
135                         Canvas display = new Canvas(Canvas.window);\r
136 \r
137                         PositionalBiasisInMovingGabor();\r
138 \r
139                 }\r
140 \r
141 \r
142 \r
143         }\r
144 \r
145 }\r
146  */\r
147 /*\r
148  * \r
149  * using Psychlops;\r
150 \r
151 namespace PsychlopsSilverlightApp\r
152 {\r
153 \r
154         public class PsychlopsMain\r
155         {\r
156 \r
157                 Psychlops.Canvas cnvs;\r
158                 int i;\r
159                 double x, y, z, t, p, temp, xx, yy;\r
160 \r
161                 //Set Target Initial Value\r
162                 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;\r
163 \r
164                 //Set Background Initial Value\r
165                 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
166                 Psychlops.Widgets.Slider thetaSpeed, DotNumber;\r
167                 Image img;\r
168 \r
169 \r
170 \r
171                 public void psychlops_main()\r
172                 {\r
173 \r
174                         cnvs = new Canvas(500, 500);\r
175 \r
176 //                      Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
177 //                      img = new Image("Resources/logo.png");\r
178 \r
179                         Interval rng = new Interval();\r
180                         thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);\r
181                         DotNumber  = new Psychlops.Widgets.Slider("DotNum",   0 <= rng <= 100, 50.0);\r
182 \r
183                         //Declare background dots and target\r
184                         Rectangle[] BGDot = new Rectangle[2048];\r
185                         for (int i = 0; i < 2048; i++)\r
186                         {\r
187                                 BGDot[i]=new Rectangle();\r
188                         }\r
189                         Rectangle[] Target= new Rectangle[10];\r
190                         for(int i=0; i<10; i++){\r
191                                 Target[i]=new Rectangle();\r
192                         }\r
193 \r
194 \r
195 \r
196                         //Declare Matrix to keep back ground dots' coordinate value\r
197                         double[] DotX=new double[2048];\r
198                         double[] DotY = new double[2048];\r
199 \r
200                         AppState.statusBar = "dvcscxz";\r
201                                                 //Set Independent variables to manipulate\r
202 \r
203 \r
204                                                 //Initialize positions of background dots\r
205                                                 for(int i=0; i<2048; i++){\r
206                                                         t=2.0*Math.PI*Math.random(1.0);\r
207                                                         p=2.0*Math.PI*Math.random(1.0);\r
208                                                         DotX[i]=t;\r
209                                                         DotY[i]=p;\r
210 \r
211                                                         x=BGRadii*Math.cos(t)*Math.cos(p);\r
212                                                         y=BGRadii*Math.sin(t)*Math.cos(p);\r
213                                                         BGDot[i].set(BGSize, BGSize);\r
214                                                         BGDot[i].centering().shift(x,y);\r
215                                                 }\r
216 \r
217                                                 //Initialize positions of targets\r
218                                                 for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
219 \r
220                                                 double COS, SIN;\r
221                                                 //DotNumber = 200;\r
222                                                 //Main stimulus loop\r
223                                                 while(true){\r
224                                                         //Clear the main window\r
225                                                         cnvs.clear();\r
226 \r
227 \r
228                                                         temp=Axis/360*2*Math.PI;\r
229                                                         COS=Math.cos(temp);\r
230                                                         SIN=Math.sin(temp);\r
231 \r
232                                                         //Calculate positions of background dots and set them\r
233                                                         for(int i=0; i<DotNumber; i++){\r
234                                                                 //Calculate in polar coordinate\r
235                                                                 t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;\r
236                                                                 p=DotY[i];\r
237 \r
238                                                                 //Save current position\r
239                                                                 DotX[i]=t;\r
240 \r
241                                                                 //Convert to Decartes coordinate\r
242                                                                 x=BGRadii*Math.cos(t)*Math.cos(p);\r
243                                                                 y=BGRadii*Math.sin(t)*Math.cos(p);\r
244                                                                 z=BGRadii*Math.sin(p);\r
245                                                                 xx=x;\r
246                                                                 yy=SIN*y+COS*z;\r
247 \r
248                                                                 //Set Dotsize and Draw them\r
249                                                                 BGDot[i].set(BGSize, BGSize);\r
250                                                                 BGDot[i].centering().shift(xx,yy);\r
251                                                                 BGDot[i].draw( Color.blue );\r
252                                                         }\r
253 \r
254                                                         //Calculate positions of targets and set them\r
255                                                         temp=Rotate*2*Math.PI/360.0;\r
256                                                         for (int i = 0; i < 5; i++)\r
257                                                         {\r
258                                                                 t = 2.0 * Math.PI/TargetNumber;\r
259                                                                 x = TargetEcce*Math.cos(i*t+temp);\r
260                                                                 y = TargetEcce*Math.sin(i*t+temp);\r
261                                                                 Target[i].centering().shift(x,y);\r
262                                                                 Target[i].fill = Color.yellow;\r
263                                                                 Target[i].draw();\r
264                                                         }\r
265 \r
266                         //                              img.centering(Mouse.position).draw();\r
267 \r
268                                                         cnvs.var(Mouse.position.x, 100, 100);\r
269                                                         cnvs.var(Mouse.position.y, 100, 140);\r
270 \r
271                                                         //Reflect drawing at the next frame;\r
272                                                         cnvs.flip();\r
273                                                 }\r
274                 }\r
275         }\r
276 \r
277 }\r
278  * */\r
279 \r
280 \r
281 \r
282 \r
283 \r
284 \r
285 /*\r
286  using Psychlops;\r
287 \r
288 namespace PsychlopsSilverlight4test\r
289 {\r
290 \r
291         public class PsychlopsMain\r
292         {\r
293 \r
294                 Psychlops.Canvas cnvs;\r
295                 int i;\r
296                 double x, y, z, t, p, temp, xx, yy;\r
297 \r
298                 //Set Target Initial Value\r
299                 double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;\r
300 \r
301                 //Set Background Initial Value\r
302                 double Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
303                 Psychlops.Widgets.Slider thetaSpeed, DotNumber;\r
304                 Image img;\r
305 \r
306 \r
307 \r
308                 public void psychlops_main()\r
309                 {\r
310                         cnvs = new Canvas(500, 500);\r
311 \r
312                         Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
313 \r
314 \r
315                         img = new Image("Resources/logo.png");\r
316 \r
317                         Interval rng = new Interval();\r
318                         thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);\r
319                         DotNumber  = new Psychlops.Widgets.Slider("DotNum",   0 <= rng <= 100, 50.0);\r
320 \r
321                         //Declare background dots and target\r
322                         Rectangle[] BGDot = new Rectangle[2048];\r
323                         for(int i=0; i<2048; i++){\r
324                                 BGDot[i]=new Rectangle();\r
325                         }\r
326                         Rectangle[] Target= new Rectangle[10];\r
327                         for(int i=0; i<10; i++){\r
328                                 Target[i]=new Rectangle();\r
329                         }\r
330 \r
331 \r
332                         //Declare Matrix to keep back ground dots' coordinate value\r
333                         double[] DotX=new double[2048];\r
334                         double[] DotY = new double[2048];\r
335 \r
336 \r
337                         //Set Independent variables to manipulate\r
338 \r
339 \r
340                         //Initialize positions of background dots\r
341                         for(int i=0; i<2048; i++){\r
342                                 t=2.0*Math.PI*Math.random(1.0);\r
343                                 p=2.0*Math.PI*Math.random(1.0);\r
344                                 DotX[i]=t;\r
345                                 DotY[i]=p;\r
346 \r
347                                 x=BGRadii*Math.cos(t)*Math.cos(p);\r
348                                 y=BGRadii*Math.sin(t)*Math.cos(p);\r
349                                 BGDot[i].set(BGSize, BGSize);\r
350                                 BGDot[i].centering().shift(x,y);\r
351                         }\r
352 \r
353                         //Initialize positions of targets\r
354                         for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
355 \r
356                         double COS, SIN;\r
357                         //DotNumber = 200;\r
358                         //Main stimulus loop\r
359                         while(true){\r
360                                 //Clear the main window\r
361                                 cnvs.clear();\r
362 \r
363 \r
364                                 temp=Axis/360*2*Math.PI;\r
365                                 COS=Math.cos(temp);\r
366                                 SIN=Math.sin(temp);\r
367 \r
368                                 //Calculate positions of background dots and set them\r
369                                 for(int i=0; i<DotNumber; i++){\r
370                                         //Calculate in polar coordinate\r
371                                         t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;\r
372                                         p=DotY[i];\r
373 \r
374                                         //Save current position\r
375                                         DotX[i]=t;\r
376 \r
377                                         //Convert to Decartes coordinate\r
378                                         x=BGRadii*Math.cos(t)*Math.cos(p);\r
379                                         y=BGRadii*Math.sin(t)*Math.cos(p);\r
380                                         z=BGRadii*Math.sin(p);\r
381                                         xx=x;\r
382                                         yy=SIN*y+COS*z;\r
383 \r
384                                         //Set Dotsize and Draw them\r
385                                         BGDot[i].set(BGSize, BGSize);\r
386                                         BGDot[i].centering().shift(xx,yy);\r
387                                         BGDot[i].draw( Color.blue );\r
388                                 }\r
389 \r
390                                 //Calculate positions of targets and set them\r
391                                 temp=Rotate*2*Math.PI/360.0;\r
392                                 for (int i = 0; i < 5; i++)\r
393                                 {\r
394                                         t = 2.0 * Math.PI/TargetNumber;\r
395                                         x = TargetEcce*Math.cos(i*t+temp);\r
396                                         y = TargetEcce*Math.sin(i*t+temp);\r
397                                         Target[i].centering().shift(x,y);\r
398                                         Target[i].fill = Color.yellow;\r
399                                         Target[i].draw();\r
400                                 }\r
401 \r
402                                 img.centering(Mouse.position).draw();\r
403 \r
404                                 cnvs.var(Mouse.position.x, 100, 100);\r
405                                 cnvs.var(Mouse.position.y, 100, 140);\r
406 \r
407                                 //Reflect drawing at the next frame;\r
408                                 cnvs.flip();\r
409                         }\r
410                 }\r
411         }\r
412 \r
413 }\r
414 */\r
415 \r
416 \r
417 /*using Psychlops;\r
418 \r
419 namespace PsychlopsSilverlight4test\r
420 {\r
421         public class PsychlopsMain\r
422         {\r
423                 public void psychlops_main()\r
424                 {\r
425                         var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
426                         var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
427                         var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
428                         var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
429                         var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
430                         var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
431                         var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
432                         var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
433 \r
434                         Canvas window = new Canvas(300, 300);\r
435 \r
436                         var figure_r = new Rectangle();\r
437                         var figure_e = new Ellipse();\r
438                         Shape figure = figure_r;\r
439                         \r
440                         while (!Keyboard.esc.pushed())\r
441                         {\r
442                                 if (System.String.Compare(figure_type, "Rectangle") == 0)\r
443                                 {\r
444                                         figure_r.set(size_x, size_y);\r
445                                         figure = figure_r;\r
446                                 }\r
447                                 else\r
448                                 {\r
449                                         figure_e.set(size_x, size_y);\r
450                                         figure = figure_e;\r
451                                 }\r
452                                 figure.fill = new Color(color_r, color_g, color_b);\r
453 \r
454                                 window.clear(Color.black);\r
455                                 figure.centering().shift(shift_x, shift_y).draw();\r
456                                 window.flip();\r
457                         }\r
458                 }\r
459         }\r
460 \r
461 }\r
462 \r
463 \r
464 \r
465 \r
466 /*\r
467 using Psychlops;\r
468 \r
469 namespace Psychlops\r
470 {\r
471 \r
472         public class RandomDots\r
473         {\r
474                 Rectangle dot;\r
475                 public Point[] cood;\r
476                 public RandomDots()\r
477                 {\r
478                         cood = new Point[250];\r
479                         dot = new Rectangle(5, 5);\r
480                 }\r
481                 public void draw()\r
482                 {\r
483                         dot.fill = Color.white;\r
484                         foreach (Point p in cood)\r
485                         {\r
486                                 dot.centering(p).draw();\r
487                         }\r
488                 }\r
489         }\r
490 \r
491 }\r
492 \r
493 \r
494 \r
495 namespace PsychlopsSilverlight4test\r
496 {\r
497 \r
498         public class PsychlopsMain\r
499         {\r
500                 Canvas cnvs;\r
501                 Image img;\r
502                 Ellipse fixation;\r
503                 Shape shape;\r
504                 Color col;\r
505                 int isize = 100;\r
506                 double tfreq = 1;\r
507                 int frames;\r
508                 RandomDots dots;\r
509                 Group g;\r
510 \r
511                 public void psychlops_main()\r
512                 {\r
513                         cnvs = new Canvas(500, 500);\r
514                         g = new Group();\r
515                         img = new Image(isize * 2, isize * 2);\r
516                         Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
517                         g.append(img);\r
518                         g.rotation = 50;\r
519                         fixation = new Ellipse(10, 10);\r
520                         fixation.fill = Color.red;\r
521                         //var poly = new Rectangle(100, 100);\r
522                         var poly = new Letters("日本語");\r
523                         //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
524                         //var poly = new Ellipse(100, 100);\r
525                         //var poly = new Line(0,0,100, 0);\r
526                         poly.fill = Color.red;\r
527                         poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
528                         shape = poly;\r
529 \r
530                         var rng = new Interval();\r
531                         var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);\r
532 \r
533                         dots = new RandomDots();\r
534 \r
535 \r
536                         while (true)\r
537                         {\r
538                                 frames++;\r
539 \r
540 \r
541                                 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));\r
542                                 col.set(Math.random(1.0));\r
543 \r
544                                 /*if (frames % 2 == 0)\r
545                                 {\r
546                                         fixation.centering().shift(100, 100);\r
547                                         fixation.draw(new Stroke(Color.blue, 3));\r
548                                 }* /\r
549 \r
550                                 fixation.centering().shift(slider, 0);\r
551                                 fixation.draw(Color.red);\r
552 \r
553                                 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
554                                 //Figures.drawGaussian(ref img, 20, 1);\r
555                                 //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
556                                 //img.centering(Mouse.position);\r
557                                 //img.draw();\r
558                                 g.centering(Mouse.position).draw();\r
559                                 g.rotation += 1;\r
560 \r
561                                 shape.centering(Mouse.position).shift(100, 0);\r
562                                 shape.draw();\r
563                                 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
564 \r
565                                 cnvs.var(frames, 0, 20);\r
566                                 //slider.value = frames / 100.0;\r
567 \r
568                                 /*if (frames % 2 != 0)\r
569                                 {\r
570                                         fixation.shift(100, 100);\r
571                                         fixation.draw(new Stroke(Color.green, 3));\r
572                                 }* /\r
573 \r
574                                 for (int i = 0; i < dots.cood.Length; i++)\r
575                                 {\r
576                                         dots.cood[i].set(Math.random(500), Math.random(500));\r
577                                 }\r
578                                 cnvs.var((double)slider, 200, 200);\r
579                                 dots.draw();\r
580 \r
581                                 cnvs.flip();\r
582                         }\r
583                 }\r
584         }\r
585 }\r
586 \r
587 **/\r
588 \r
589 \r
590 /*\r
591 \r
592 using Psychlops;\r
593 namespace PsychlopsSilverlight4test\r
594 {\r
595 \r
596         public class PsychlopsMain\r
597         {\r
598                 Canvas cnvs;\r
599                 Rectangle[] rect;\r
600                 int n;\r
601 \r
602                 public void psychlops_main()\r
603                 {\r
604                         n = 1;\r
605                         cnvs = new Canvas(500, 500);\r
606                         rect = new Rectangle[n];\r
607                         for (int i = 0; i < n; i++)\r
608                         {\r
609                                 rect[i] = new Rectangle(10, 10);\r
610                                 rect[i].fill = Color.red;\r
611                         }\r
612                         Interval rng = new Interval();\r
613                         var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);\r
614 \r
615                         while (true)\r
616                         {\r
617                                 cnvs.clear();\r
618                                 for (int i = 0; i < n; i++)\r
619                                 {\r
620                                         rect[i].centering().shift(slider * i*3, i*3).draw();\r
621                                 }\r
622                                 cnvs.flip();\r
623                         }\r
624                 }\r
625         }\r
626 }\r
627 \r
628 */\r
629 \r
630 /*\r
631 using Psychlops;\r
632 \r
633 namespace PsychlopsSilverlight4test\r
634 {\r
635         public class PsychlopsMain\r
636         {\r
637                 public void psychlops_main()\r
638                 {\r
639                         Canvas window = new Canvas(300, 300);\r
640 \r
641                         var figure_r = new Rectangle();\r
642                         var figure_e = new Ellipse();\r
643                         figure_r.set(100,100).centering().shift(0, 0);\r
644                         figure_e.set(100,100).centering().shift(0, 0);\r
645 \r
646                         while (!Keyboard.esc.pushed())\r
647                         {\r
648                                 figure_r.fill = new Color(0, 0, 1);\r
649                                 figure_r.centering(new Point(100,100)).draw();\r
650                                 figure_e.fill = new Color(1, 0, 0);\r
651                                 figure_e.centering(new Point(100, 100)).draw();\r
652                                 window.flip();\r
653                         }\r
654                 }\r
655         }\r
656 \r
657 }\r
658 \r
659 /*\r
660 \r
661 \r
662 \r
663 using Psychlops;\r
664 \r
665 namespace PsychlopsSilverlight4test\r
666 {\r
667         public class PsychlopsMain\r
668         {\r
669                 public void psychlops_main()\r
670                 {\r
671                         var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
672                         var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
673                         var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
674                         var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
675                         var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
676                         var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
677 \r
678                         Canvas window = new Canvas(300, 300);\r
679 \r
680                         var figure_r = new Rectangle();\r
681                         var figure_e = new Ellipse();\r
682                         figure_r.centering().shift(0, 0);\r
683                         figure_e.centering().shift(0, 0);\r
684 \r
685                         int frame = 0;\r
686                         int direction = 1, motion_dir = 1;\r
687 \r
688                         while (!Keyboard.esc.pushed())\r
689                         {\r
690                                 window.clear();\r
691 \r
692                                 if (frame % 30 == 0)\r
693                                 {\r
694                                         direction = direction * -1;\r
695 \r
696                                 }\r
697 \r
698                                 if (frame % 90 == 0)\r
699                                 {\r
700                                         motion_dir *= -1;\r
701                                 }\r
702 \r
703                                 figure_r.resize(figure_r.getWidth() + direction * 1, figure_r.getHeight() + direction * 1);\r
704                                 figure_r.shift(motion_dir * 1, 0);\r
705                                 figure_r.fill = new Color(color_r, color_g, color_b);\r
706 \r
707                                 figure_e.resize(figure_e.getWidth() + direction * 1, figure_e.getHeight() + direction * 1);\r
708                                 figure_e.shift(motion_dir * 1, 0);\r
709                                 figure_e.fill = new Color(color_r, color_g, color_b);\r
710 \r
711                                 if (System.String.Compare(figure_type, "Rectangle") == 0)\r
712                                 {\r
713                                         figure_r.draw();\r
714                                 }\r
715                                 else\r
716                                 {\r
717                                         figure_e.draw();\r
718                                 }\r
719 \r
720 \r
721                                 frame++;\r
722 \r
723 \r
724                                 window.flip();\r
725                         }\r
726                 }\r
727         }\r
728 \r
729 }\r
730  * */\r
731 \r
732 \r
733 /*\r
734 using Psychlops;\r
735 \r
736 namespace PsychlopsSilverlight4test\r
737 {\r
738         public class PsychlopsMain\r
739         {\r
740                 public void psychlops_main()\r
741                 {\r
742                         var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
743                         var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
744                         var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
745                         var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
746                         var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
747                         var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
748                         var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
749                         var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
750 \r
751                         Canvas window = new Canvas(300, 300);\r
752 \r
753                         var figure_r = new Rectangle();\r
754                         var figure_e = new Ellipse();\r
755                         Shape figure = figure_r;\r
756                         \r
757                         while (!Keyboard.esc.pushed())\r
758                         {\r
759                                 if (System.String.Compare(figure_type, "Rectangle") == 0)\r
760                                 {\r
761                                         figure_r.set(size_x, size_y);\r
762                                         figure = figure_r;\r
763                                 }\r
764                                 else\r
765                                 {\r
766                                         figure_e.set(size_x, size_y);\r
767                                         figure = figure_e;\r
768                                 }\r
769                                 figure.fill = new Color(color_r, color_g, color_b);\r
770 \r
771                                 window.clear(Color.black);\r
772                                 figure.centering().shift(shift_x, shift_y).draw();\r
773                                 window.flip();\r
774                         }\r
775                 }\r
776         }\r
777 \r
778 }\r
779 */\r
780 \r
781 \r
782 /*\r
783 using Psychlops;\r
784 \r
785 namespace Psychlops\r
786 {\r
787 \r
788         public class RandomDots\r
789         {\r
790                 Rectangle dot;\r
791                 public Point[] cood;\r
792                 public RandomDots()\r
793                 {\r
794                         cood = new Point[250];\r
795                         dot = new Rectangle(5, 5);\r
796                 }\r
797                 public void draw()\r
798                 {\r
799                         dot.fill = Color.white;\r
800                         foreach (Point p in cood)\r
801                         {\r
802                                 dot.centering(p).draw();\r
803                         }\r
804                 }\r
805         }\r
806 \r
807 }\r
808 \r
809 \r
810 namespace PsychlopsSilverlight4test\r
811 {\r
812 \r
813         public class PsychlopsMain\r
814         {\r
815                 Canvas cnvs;\r
816                 Image img;\r
817                 Rectangle fixation;\r
818                 Shape shape;\r
819                 Color col;\r
820                 int isize = 100;\r
821                 double tfreq = 1;\r
822                 int frames;\r
823                 RandomDots dots;\r
824 \r
825                 public void psychlops_main()\r
826                 {\r
827                         cnvs = new Canvas(500, 500);\r
828                         img = new Image(isize * 2, isize * 2);\r
829                         fixation = new Rectangle(10, 10);\r
830                         fixation.fill = Color.red;\r
831                         //var poly = new Rectangle(100, 100);\r
832                         var poly = new Letters("日本語");\r
833                         //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
834                         //var poly = new Ellipse(100, 100);\r
835                         //var poly = new Line(0,0,100, 0);\r
836                         poly.fill = Color.red;\r
837                         poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
838                         shape = poly;\r
839 \r
840                         var rng = new Interval();\r
841                         var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);\r
842 \r
843                         dots = new RandomDots();\r
844 \r
845 \r
846                         while(true) {\r
847                                 frames++;\r
848                                 \r
849                                 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));\r
850                                 col.set(Math.random(1.0));\r
851 \r
852                                 fixation.centering();\r
853                                 fixation.draw(Color.red);\r
854 \r
855                                 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
856                                 //Figures.drawGaussian(ref img, 20, 1);\r
857                                 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
858                                 img.centering(Mouse.position);\r
859                                 img.draw();\r
860 \r
861                                 shape.centering(Mouse.position).shift(100,0);\r
862                                 shape.draw();\r
863                                 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
864 \r
865                                 cnvs.var(frames, 20, 20);\r
866                                 slider.value = frames/100.0;\r
867 \r
868                                 fixation.shift(100,100);\r
869                                 fixation.draw(new Stroke(Color.blue, 3));\r
870 \r
871                                 for (int i=0; i<dots.cood.Length; i++)\r
872                                 {\r
873                                         dots.cood[i].set(Math.random(500), Math.random(500));\r
874                                 }\r
875                                 dots.draw();\r
876 \r
877                                 cnvs.flip();\r
878                         }\r
879                 }\r
880         }\r
881 \r
882 }\r
883 */