OSDN Git Service

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