OSDN Git Service

clock interval
[psychlops/silverlight.git] / test3 / PsychlopsMain.cs
1 using Psychlops;\r
2 \r
3 namespace PsychlopsSilverlight3test\r
4 {\r
5 \r
6         public class PsychlopsMain\r
7         {\r
8                 Canvas cnvs;\r
9                 Image img;\r
10                 Rectangle fixation;\r
11                 Shape shape;\r
12                 Color col;\r
13                 int isize = 100;\r
14                 double tfreq = 1;\r
15                 int frames;\r
16 \r
17                 public void psychlops_main()\r
18                 {\r
19                         cnvs = new Canvas(500, 500);\r
20                         img = new Image(isize * 2, isize * 2);\r
21                         fixation = new Rectangle(10, 10);\r
22                         fixation.fill = Color.red;\r
23                         var poly = new Rectangle(100, 100);\r
24                         //var poly = new Letters("日本語");\r
25                         //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
26                         //var poly = new Ellipse(100, 100);\r
27                         //var poly = new Line(0,0,100, 0);\r
28                         poly.fill = Color.red;\r
29                         poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
30                         shape = poly;\r
31 \r
32 \r
33                         while(true) {\r
34                                 frames++;\r
35                                 \r
36                                 cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));\r
37                                 col.set(Math.random(1.0));\r
38 \r
39                                 fixation.centering();\r
40                                 fixation.draw(Color.red);\r
41 \r
42                                 //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
43                                 //Figures.drawGaussian(ref img, 20, 1);\r
44                                 Figures.drawGrating(ref img, 300, 300, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
45                                 img.centering(Mouse.position);\r
46                                 img.draw();\r
47 \r
48                                 shape.centering(Mouse.position).shift(100,0);\r
49                                 shape.draw();\r
50                                 if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
51 \r
52                                 cnvs.var(frames, 10, 20);\r
53 \r
54                                 fixation.shift(100,100);\r
55                                 fixation.draw(new Stroke(Color.blue, 3));\r
56 \r
57                                 cnvs.flip();\r
58                         }\r
59                 }\r
60         }\r
61 \r
62 }\r