OSDN Git Service

5
[psychlops/silverlight.git] / test5 / PsychlopsMain.cs
index e69a680..f1d7bb8 100644 (file)
-using Psychlops;\r
+//Psychlops Code Template\r
+//    Please visit following web site to get sample codes.\r
+//    http://psychlops.sourceforge.jp/ja/?StartCode\r
+//    CodeDresser at following address is also available to view the code.\r
+//    http://visitope.org/Tools/codedresser.html\r
+\r
+///+ 0 Setup Psychlops Circumstances\r
+//// 0 Setup Psychlops Circumstances\r
+using Psychlops;\r
 \r
 namespace PsychlopsSilverlightApp\r
 {\r
 \r
        public class PsychlopsMain\r
        {\r
+               // Psychlops Win32 1.5.5 / 20110927\r
+               ///- 0 Setup Psychlops Circumstances\r
 \r
+               Psychlops.Widgets.Slider SOAFrames, gap, wavelength, contrast;\r
 \r
                public void psychlops_main() {\r
 \r
+                       ///+ 1 Declaration /////////////////////////////////////////////////////////////\r
+                       //// 1 Declaration\r
+                       // declare default window and variables for its parameters\r
+                       Canvas cnvs = new Canvas(900,600, Canvas.window, Display.primary);\r
+                       double CANVAS_FRAMENUM;\r
+                       int CANVAS_REFRESHRATE;\r
+                       Color DEFAULT_BG_COLOR = new Color();\r
+\r
+                       int gratingwidth = 500, gratingheight = 100;\r
+                       double shift=0.0;\r
+                       Color color = new Color(0.0,0.0,0.0);\r
+                       Rectangle grating = new Rectangle();\r
+\r
+\r
+                       Interval rng = new Interval();\r
+\r
+                       //declare local variables around here\r
+\r
+                       ///- 1 Declaration /////////////////////////////////////////////////////////////\r
+\r
+                       ///+ 2 Initialization //////////////////////////////////////////////////////////\r
+                       //// 2 Initialization\r
+\r
+                       // Set initial values for local variables\r
+                       CANVAS_REFRESHRATE = (int)cnvs.getRefreshRate();\r
+                       CANVAS_FRAMENUM = 0;\r
+                       DEFAULT_BG_COLOR.set(127.0/255.0,127.0/255.0,127.0/255.0,1.0); // default background color is 127/255 mid-gray\r
+\r
+\r
+                       SOAFrames = new Psychlops.Widgets.Slider("SOA Frames", 1  <=rng<=20  ,  1   , 1);\r
+                       SOAFrames.value = 5;\r
+                       gap = new Psychlops.Widgets.Slider("Grating gap" , 0  <=rng<=200 ,  1   , 10);\r
+                       gap.value = 20;\r
+                       wavelength = new Psychlops.Widgets.Slider("Wave Length", 1 <= rng <= 50, 1, 10);\r
+                       wavelength.value = 30.0;\r
+                       contrast = new Psychlops.Widgets.Slider("Contrast"    , 0.0<=rng<=1.0 ,  0.1 , 0.01);\r
+                       contrast.value = 0.1;\r
+\r
+                       // Draw Offline images around here\r
+\r
+                       // Offline Movie calculation using Image array around here\r
+\r
+                       ///- 2 Initialization //////////////////////////////////////////////////////////\r
+\r
+                       ///+ 3 Drawing /////////////////////////////////////////////////////////////////\r
+                       //// 3 Drawing\r
+                       while(!Keyboard.esc.pushed()) {\r
+                       cnvs.clear(DEFAULT_BG_COLOR);\r
+\r
+                       //Write draw commands for realtime figure calculation and drawing around here\r
+\r
+\r
+                       if(Math.mod(CANVAS_FRAMENUM,SOAFrames) == 0){shift += 1;}\r
+\r
+                       grating.set(1,gratingheight).centering().shift(-gratingwidth/2, 0);\r
+                       for(int i=0; i<gratingwidth; i++) {\r
+                               color.set(\r
+                                                       + 0.25*contrast*Math.sin(2*Math.PI*(i*2.0/wavelength + 0.50 * shift))\r
+                                                       + 0.25*contrast*Math.sin(2*Math.PI*(i*3.0/wavelength + 0.75 * shift))\r
+                                                       +0.5\r
+                                                       );\r
+                               grating.shift(1, 0);\r
+                               grating.draw(color);\r
+                       }\r
+\r
+                       grating.set(1,gratingheight).centering().shift(-gratingwidth/2, -gratingheight-gap);\r
+                       for(int i=0; i<gratingwidth; i++) {\r
+                               color.set(\r
+                                                       + 0.25*contrast*Math.sin(2.0*Math.PI*(i*2.0/wavelength + 0.50 * shift))\r
+                                                       +0.5\r
+                                                       );\r
+                               grating.shift(1,0);\r
+                               grating.draw(color);\r
+                       }\r
+\r
+                       grating.set(1,gratingheight).centering().shift(-gratingwidth/2, gratingheight+gap);\r
+                       for(int i=0; i<gratingwidth; i++) {\r
+                               color.set(\r
+                                                       + 0.25*contrast*Math.sin(2.0*Math.PI*(i*3.0/wavelength + 0.75 * shift))\r
+                                                       +0.5\r
+                                                       );\r
+                               grating.shift(1,0);\r
+                               grating.draw(color);\r
+                       }\r
+\r
+                       cnvs.flip();\r
+                       CANVAS_FRAMENUM++;\r
+                       }\r
+                       ///- 3 Drawing /////////////////////////////////////////////////////////////////\r
+\r
+               }\r
+\r
+\r
+       }\r
+\r
+}\r
+\r
+/*\r
+               public void psychlops_main() {\r
+\r
        Canvas display = new Canvas(768,768);\r
 \r
        double rect_size = 100;\r
@@ -132,11 +243,12 @@ Math.PI*Math.sin(Math.PI/2*i+2*Math.PI*phase*TF/refresh);
 \r
 }\r
 \r
-\r
-\r
        }\r
 \r
 }\r
+*/\r
+\r
+\r
 /*\r
 \r
 using Psychlops;\r