OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/psychlops/silverlight
[psychlops/silverlight.git] / test4 / PsychlopsMain.cs
index 261c75d..aafe412 100644 (file)
@@ -1,5 +1,6 @@
 ///+ Prefix linkto BasicCode1\r
 //// Lines for set up Psychlops environment\r
+<<<<<<< HEAD
 using Psychlops;\r
 \r
 namespace PsychlopsSilverlight4test\r
@@ -102,44 +103,132 @@ namespace PsychlopsSilverlight4test
 \r
 \r
 /*\r
+=======
+>>>>>>> 06a470a0e79a283223a73d8c5f6e43ef76174d97
 using Psychlops;\r
 \r
-namespace PsychlopsSilverlight4test\r
+namespace PsychlopsSilverlightApp\r
 {\r
 \r
        public class PsychlopsMain\r
-       {\r
+       {///- Prefix linkto BasicCode1\r
+\r
+\r
+               ///+ Main Routine\r
+               //// Psychlops runs at the first line of this function psychlops_main().\r
+               public void psychlops_main()\r
+               {\r
+                       ///+ 0 linkto BasicCode3_1a\r
+                       ////Prepare global parameters\r
+                       int maxrectnum = 200;\r
+                       int rectnum = 100;\r
+                       double rectsize = 5.0;\r
+                       Rectangle[] rect = StaticFunctions.NewArray<Rectangle>(maxrectnum);\r
+                       double[] rectcolorR = new double[maxrectnum];\r
+                       double[] rectcolorG = new double[maxrectnum];\r
+                       double[] rectcolorB = new double[maxrectnum];\r
+                       ///- 0 linkto BasicCode3_1a\r
+\r
+                       Canvas window = new Canvas(Canvas.window);\r
+                       var img = new Image("logo.png");\r
+\r
+\r
+                       ///+ 1 linkto BasicCode3_1a\r
+                       ////Initialize\r
+                       for (int i = 0; i < rectnum; i++)\r
+                       {\r
+                               ///+ 1.1 set1\r
+                               ////set positions and sizes\r
+                               rect[i].set(rectsize, rectsize); //Set a size of rectangles.\r
+                               rect[i].centering();\r
+                               rect[i].shift((i - 0.5 * rectnum) * rectsize * 1.5,\r
+                                                                                          (i - 0.5 * rectnum) * rectsize * 1.5); //Move Rectangles to initial positions\r
+                               ///- 1.1 set1\r
+                               ///+ 1.2 set2\r
+                               ////set colors\r
+                               rectcolorR[i] = Math.random(1.0) * 0.5; //Set R values. Note that "i" is converted to double-type.\r
+                               rectcolorG[i] = Math.random(1.0) * 0.5; //Set G values. Note that "i" is converted to double-type.\r
+                               rectcolorB[i] = Math.random(1.0) * 0.5; //Set B values. Note that "i" is converted to double-type.\r
+                               ///- 1.2 set2\r
+                       }\r
+                       ///- 1 linkto BasicCode3_1a\r
+\r
+                       ///+ 2 drawing\r
+                       ////drawing objects\r
+                       ///+ 2.1 linkto BasicCode3_2a\r
+                       ////Prepare variables for movie control;\r
+                       int frame = 0;\r
+                       int motion_dir = 1;\r
+                       double Horizontal_shift, Vertical_shift;\r
+                       ///- 2.1 linkto BasicCode3_2a\r
 \r
-               Psychlops.Widgets.Slider rect_size;\r
-               Psychlops.Widgets.Slider rect_lum;\r
-               Psychlops.Widgets.Slider bg_lum;\r
+                       while (!Keyboard.esc.pushed())\r
+                       {\r
+                               window.clear(Color.black);\r
+                               for (int i = 0; i < rectnum; i++)\r
+                               {\r
+                                       ///+ 2.2 loopset1\r
+                                       ////set positions and sizes\r
+\r
+                                       Horizontal_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 100.0; //Calculate horizontal displacement from the center.\r
+                                       Vertical_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 0.0;//Calculate vertical displacement from the center.\r
+                                       rect[i].resize(rectsize, rectsize); //Resize rectangles.\r
+                                       rect[i].centering(); //Rectangles are moved to the center...\r
+                                       rect[i].shift(Horizontal_shift + (i - 0.5 * rectnum) * rectsize * 1.5,\r
+                                                                 Vertical_shift + (i - 0.5 * rectnum) * rectsize * 1.5); //and then move to designated positions\r
+                                       ///- 2.2 loopset1\r
+\r
+                                       ///+ 2.3 linkto BasicCode3_2a\r
+                                       ////set colors \r
+                                       rectcolorR[i] = Math.random(1.0) * 0.5; //Set R values. Note that "i" is converted to double-type.\r
+                                       rectcolorG[i] = Math.random(1.0) * 0.5; //Set G values. Note that "i" is converted to double-type.\r
+                                       rectcolorB[i] = Math.random(1.0) * 0.5; //Set B values. Note that "i" is converted to double-type.\r
+                                       ///- 2.3 linkto BasicCode3_2a\r
+\r
+                               }\r
+                               ///+ 2.4 linkto BasicCode3_1a\r
+                               for (int i = 0; i < rectnum; i++)\r
+                               {\r
+                                       rect[i].draw(new Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors.\r
+                               }\r
+                               window.flip();\r
+                               ///- 2.4 linkto BasicCode3_1a\r
+                               frame++;\r
+                       }\r
+                       ///- 2 drawing\r
 \r
+               }\r
+               ///- Main Routine\r
 \r
+\r
+       }\r
+\r
+}\r
+\r
+\r
+\r
+\r
+\r
+/*\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+\r
+       public class PsychlopsMain\r
+       {\r
                void RectLuminance()\r
                {\r
                        Canvas display = new Canvas(Canvas.window);\r
-                       Interval rng = new Interval();\r
-                       rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 10.0);\r
-                       rect_lum = new Psychlops.Widgets.Slider("Rect Luminance", 0.0 <= rng <= 1.0, 0.1);\r
-                       bg_lum = new Psychlops.Widgets.Slider("BG Luminance", 0.0 <= rng <= 1.0, 0.1);\r
-                       Ellipse drawee = new Ellipse(100, 100);\r
-                       display.showFPS();\r
-                       display.watchFPS();\r
-\r
-                       Rectangle rect = new Rectangle(rect_size, rect_size);\r
-                       rect.centering();\r
-\r
+                       Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
+                       Letters le = new Letters("Reload to restart");\r
+                       le.fill = Color.black;\r
+                       le.align = Letters.HorizontalAlign.center;\r
 \r
-                       Clock before = new Clock(), after = new Clock();\r
                        while (!Keyboard.esc.pushed())\r
                        {\r
-                               Display.clear(bg_lum);\r
-                               rect.resize(rect_size, rect_size).draw(rect_lum);\r
-                               after.update();\r
-                               display.var((after - before).at_msec(), 100, 100, Color.green);\r
-                               display.var((after - before).at_msec(), 100, 200, Color.green);\r
-                               drawee.centering().shift(Math.random(100), 0);\r
-                               drawee.draw(Color.black);\r
+                               Display.clear(Color.white);\r
+                               le.centering().shift(-200,-10).draw();\r
                                Display.flip();\r
                        }\r
 \r
@@ -157,7 +246,7 @@ namespace PsychlopsSilverlight4test
 }\r
 */\r
 \r
-\r
+*/\r
 \r
 \r
 \r