OSDN Git Service

456
[psychlops/silverlight.git] / test4 / PsychlopsMain.cs
index b9b3d57..120388a 100644 (file)
-using Psychlops;\r
+\r
+///+ Prefix\r
+//// Lines for set up Psychlops environment\r
+using Psychlops;\r
 \r
-namespace PsychlopsSilverlight4test\r
+namespace PsychlopsSilverlightApp\r
 {\r
+\r
        public class PsychlopsMain\r
-       {\r
+       {///- Prefix\r
+\r
+               ///+ Main Routine\r
+               //// Psychlops runs at the first line of this function psychlops_main().\r
                public void psychlops_main()\r
                {\r
-                       var elem = Psychlops.Widgets.Browser.Element.byID("TheInput");\r
-\r
-                       Canvas window = new Canvas(500,500);\r
-\r
-                       var figure = new Rectangle();\r
-                       figure.set( 100, 100 );\r
-                       figure.fill = new Color(1.0, 0.0, 0.0);\r
-                       \r
+                       ///+ 1\r
+                       //// Set a window for drawing stimulus\r
+                       Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.\r
+                       // You can write this statement as" Canvas window = new Canvas(Canvas.fullscreen); " for fullscreen mode\r
+                       // or as " Canvas window = new Canvas(1024, 768, 32, 60.0); " This statement changes screenmode to 1024 x 768, 32bit color, 60 Hz refresh.\r
+                       ///- 1\r
+\r
+                       var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
+                       var SIZE_X = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
+                       var SIZE_Y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
+                       var SHIFT_X = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
+                       var SHIFT_Y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
+                       var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
+                       var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
+                       var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
+\r
+\r
+                       ///+ 2\r
+                       ////  Set a figure size, position and color.\r
+                       Rectangle figure = new Rectangle();\r
+                       Ellipse figure2 = new Ellipse();\r
+\r
+                       window.flip(); // Reflect the drawing for the display by flipping frame buffers.\r
+                       // Till this point, you will not see drawn figures.\r
+                       ///- 2\r
+\r
+                       ///+ 3 \r
+                       //// Detect a Keyboard input\r
                        while (!Keyboard.esc.pushed())\r
                        {\r
-                               window.clear(Color.black);\r
-                               figure.centering().shift(elem.getValueAsDouble(), 1).draw();\r
-                               window.flip();\r
-                       }\r
-               }\r
-       }\r
-\r
-}\r
-\r
 \r
+                               window.clear();\r
 \r
+                               if ("Rectangle".Equals(FIGURE))\r
+                               {\r
+                                       figure.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
+                                       figure.centering();   // Centering the figure in the window\r
+                                       figure.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector.    \r
+                                       figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
+                               }\r
+                               else\r
+                               {\r
+                                       figure2.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
+                                       figure2.centering();   // Centering the figure in the window\r
+                                       figure2.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector.    \r
+                                       figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
+                               }\r
 \r
-/*\r
-using Psychlops;\r
+                               window.flip();\r
 \r
-namespace Psychlops\r
-{\r
+                       } //exit a program when the escape key is pressed down.\r
+                       ///- 3\r
 \r
-       public class RandomDots\r
-       {\r
-               Rectangle dot;\r
-               public Point[] cood;\r
-               public RandomDots()\r
-               {\r
-                       cood = new Point[250];\r
-                       dot = new Rectangle(5, 5);\r
-               }\r
-               public void draw()\r
-               {\r
-                       dot.fill = Color.white;\r
-                       foreach (Point p in cood)\r
-                       {\r
-                               dot.centering(p).draw();\r
-                       }\r
                }\r
+               ///- Main Routine\r
+\r
        }\r
 \r
 }\r
 \r
 \r
-namespace PsychlopsSilverlight4test\r
-{\r
-\r
-       public class PsychlopsMain\r
-       {\r
-               Canvas cnvs;\r
-               Image img;\r
-               Rectangle fixation;\r
-               Shape shape;\r
-               Color col;\r
-               int isize = 100;\r
-               double tfreq = 1;\r
-               int frames;\r
-               RandomDots dots;\r
-\r
-               public void psychlops_main()\r
-               {\r
-                       cnvs = new Canvas(500, 500);\r
-                       img = new Image(isize * 2, isize * 2);\r
-                       fixation = new Rectangle(10, 10);\r
-                       fixation.fill = Color.red;\r
-                       //var poly = new Rectangle(100, 100);\r
-                       var poly = new Letters("日本語");\r
-                       //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
-                       //var poly = new Ellipse(100, 100);\r
-                       //var poly = new Line(0,0,100, 0);\r
-                       poly.fill = Color.red;\r
-                       poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
-                       shape = poly;\r
-\r
-                       var rng = new Interval();\r
-                       var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);\r
-\r
-                       dots = new RandomDots();\r
-\r
-\r
-                       while(true) {\r
-                               frames++;\r
-                               \r
-                               cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5));\r
-                               col.set(Math.random(1.0));\r
-\r
-                               fixation.centering();\r
-                               fixation.draw(Color.red);\r
-\r
-                               //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
-                               //Figures.drawGaussian(ref img, 20, 1);\r
-                               Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
-                               img.centering(Mouse.position);\r
-                               img.draw();\r
-\r
-                               shape.centering(Mouse.position).shift(100,0);\r
-                               shape.draw();\r
-                               if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
-\r
-                               cnvs.var(frames, 20, 20);\r
-                               slider.value = frames/100.0;\r
-\r
-                               fixation.shift(100,100);\r
-                               fixation.draw(new Stroke(Color.blue, 3));\r
-\r
-                               for (int i=0; i<dots.cood.Length; i++)\r
-                               {\r
-                                       dots.cood[i].set(Math.random(500), Math.random(500));\r
-                               }\r
-                               dots.draw();\r
-\r
-                               cnvs.flip();\r
-                       }\r
-               }\r
-       }\r
-\r
-}\r
-*/
\ No newline at end of file