OSDN Git Service

b9b3d5762b451a8a8522472d579bf5ef886628ad
[psychlops/silverlight.git] / test4 / PsychlopsMain.cs
1 using Psychlops;\r
2 \r
3 namespace PsychlopsSilverlight4test\r
4 {\r
5         public class PsychlopsMain\r
6         {\r
7                 public void psychlops_main()\r
8                 {\r
9                         var elem = Psychlops.Widgets.Browser.Element.byID("TheInput");\r
10 \r
11                         Canvas window = new Canvas(500,500);\r
12 \r
13                         var figure = new Rectangle();\r
14                         figure.set( 100, 100 );\r
15                         figure.fill = new Color(1.0, 0.0, 0.0);\r
16                         \r
17                         while (!Keyboard.esc.pushed())\r
18                         {\r
19                                 window.clear(Color.black);\r
20                                 figure.centering().shift(elem.getValueAsDouble(), 1).draw();\r
21                                 window.flip();\r
22                         }\r
23                 }\r
24         }\r
25 \r
26 }\r
27 \r
28 \r
29 \r
30 \r
31 /*\r
32 using Psychlops;\r
33 \r
34 namespace Psychlops\r
35 {\r
36 \r
37         public class RandomDots\r
38         {\r
39                 Rectangle dot;\r
40                 public Point[] cood;\r
41                 public RandomDots()\r
42                 {\r
43                         cood = new Point[250];\r
44                         dot = new Rectangle(5, 5);\r
45                 }\r
46                 public void draw()\r
47                 {\r
48                         dot.fill = Color.white;\r
49                         foreach (Point p in cood)\r
50                         {\r
51                                 dot.centering(p).draw();\r
52                         }\r
53                 }\r
54         }\r
55 \r
56 }\r
57 \r
58 \r
59 namespace PsychlopsSilverlight4test\r
60 {\r
61 \r
62         public class PsychlopsMain\r
63         {\r
64                 Canvas cnvs;\r
65                 Image img;\r
66                 Rectangle fixation;\r
67                 Shape shape;\r
68                 Color col;\r
69                 int isize = 100;\r
70                 double tfreq = 1;\r
71                 int frames;\r
72                 RandomDots dots;\r
73 \r
74                 public void psychlops_main()\r
75                 {\r
76                         cnvs = new Canvas(500, 500);\r
77                         img = new Image(isize * 2, isize * 2);\r
78                         fixation = new Rectangle(10, 10);\r
79                         fixation.fill = Color.red;\r
80                         //var poly = new Rectangle(100, 100);\r
81                         var poly = new Letters("日本語");\r
82                         //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
83                         //var poly = new Ellipse(100, 100);\r
84                         //var poly = new Line(0,0,100, 0);\r
85                         poly.fill = Color.red;\r
86                         poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
87                         shape = poly;\r
88 \r
89                         var rng = new Interval();\r
90                         var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);\r
91 \r
92                         dots = new RandomDots();\r
93 \r
94 \r
95                         while(true) {\r
96                                 frames++;\r
97                                 \r
98                                 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));\r
99                                 col.set(Math.random(1.0));\r
100 \r
101                                 fixation.centering();\r
102                                 fixation.draw(Color.red);\r
103 \r
104                                 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
105                                 //Figures.drawGaussian(ref img, 20, 1);\r
106                                 Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
107                                 img.centering(Mouse.position);\r
108                                 img.draw();\r
109 \r
110                                 shape.centering(Mouse.position).shift(100,0);\r
111                                 shape.draw();\r
112                                 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
113 \r
114                                 cnvs.var(frames, 20, 20);\r
115                                 slider.value = frames/100.0;\r
116 \r
117                                 fixation.shift(100,100);\r
118                                 fixation.draw(new Stroke(Color.blue, 3));\r
119 \r
120                                 for (int i=0; i<dots.cood.Length; i++)\r
121                                 {\r
122                                         dots.cood[i].set(Math.random(500), Math.random(500));\r
123                                 }\r
124                                 dots.draw();\r
125 \r
126                                 cnvs.flip();\r
127                         }\r
128                 }\r
129         }\r
130 \r
131 }\r
132 */