OSDN Git Service

321
[psychlops/silverlight.git] / test3 / PsychlopsMain.cs
1 using Psychlops;\r
2 \r
3 namespace PsychlopsSilverlight3test\r
4 {\r
5         public class PsychlopsMain\r
6         {\r
7                 Canvas cnvs;\r
8                 Image img;\r
9                 Rectangle fixation;\r
10                 int isize = 100;\r
11                 double tfreq = 1;\r
12 \r
13                 public void initialize()\r
14                 {\r
15                         cnvs = new Canvas(500, 500);\r
16                         img = new Image(isize * 2, isize * 2);\r
17                         fixation = new Rectangle(10, 10);\r
18                         cnvs.clear(Color.gray);\r
19                 }\r
20 \r
21                 public void each_frames()\r
22                 {\r
23                         cnvs.clear(new Color(Mouse.left.pressed() ? 1.0 : 0.5));\r
24                         img.field(\r
25                                 (x, y) => new Color(.5 + Math.gaussian(Math.radius(x - isize, y - isize), isize / 8.0) * .5 * Math.sin(cnvs.frame * 2 * Math.PI / tfreq / 60 + x / 3.0))\r
26                                         );\r
27                         img.centering(Mouse.position);\r
28                         //img.shift(1,0);\r
29                         img.draw();\r
30                         fixation.centering();\r
31                         fixation.draw(Color.red);\r
32                         cnvs.flip();\r
33                 }\r
34         }\r
35 }\r