OSDN Git Service

pooling
authorHOSOKAWA Kenchi <hskwk@inter7.jp>
Sat, 17 Jul 2010 23:34:37 +0000 (08:34 +0900)
committerHOSOKAWA Kenchi <hskwk@inter7.jp>
Sat, 17 Jul 2010 23:41:05 +0000 (08:41 +0900)
dev4/PsychlopsSilverlight4.csproj
dev4/psychlops/core/graphic/canvas.cs
dev4/psychlops/core/graphic/module.cs
dev4/psychlops/core/graphic/shape.cs
dev4/psychlops/extention/experiments/experiments.cs [new file with mode: 0644]
dev4/psychlops/extention/math/probit.cs [new file with mode: 0644]
dev4/psychlops/extention/media/dom.cs [new file with mode: 0644]
test4/PsychlopsSilverlight4test.csproj
test4/Store.cs [new file with mode: 0644]

index 230fa1e..e33dd51 100644 (file)
@@ -53,6 +53,7 @@
     <Reference Include="mscorlib" />\r
     <Reference Include="system" />\r
     <Reference Include="System.Core" />\r
+    <Reference Include="System.Windows.Controls.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
     <Reference Include="System.Xml" />\r
     <Reference Include="System.Net" />\r
     <Reference Include="System.Windows.Browser" />\r
@@ -74,6 +75,8 @@
     <Compile Include="psychlops\core\math\interval.cs" />\r
     <Compile Include="psychlops\core\math\matrix.cs" />\r
     <Compile Include="psychlops\core\math\util.cs" />\r
+    <Compile Include="psychlops\extention\experiments\experiments.cs" />\r
+    <Compile Include="psychlops\extention\math\probit.cs" />\r
     <Compile Include="psychlops\extention\media\dom.cs" />\r
     <Compile Include="psychlops\extention\media\svg.cs" />\r
     <Compile Include="psychlops\extention\standard\figures.cs" />\r
index a695257..568565b 100644 (file)
@@ -19,11 +19,26 @@ namespace Psychlops
 \r
                public class StackableDrawable : Drawable\r
                {\r
-                       protected System.Collections.Generic.Queue<Internal.PrimitiveFigure> stack;\r
+//                     protected System.Collections.Generic.Queue<Internal.PrimitiveFigure> stack;\r
+                       internal Internal.PrimitiveFigure[] stack;\r
+                       internal int stackN;\r
+                       internal Line[] lineStack;\r
+                       internal int lineStackN;\r
+                       internal Rectangle[] rectStack;\r
+                       internal int rectStackN;\r
+\r
 \r
                        public StackableDrawable()\r
                        {\r
-                               stack = new System.Collections.Generic.Queue<Internal.PrimitiveFigure>();\r
+//                             stack = new System.Collections.Generic.Queue<Internal.PrimitiveFigure>();\r
+                               stack = new Internal.PrimitiveFigure[40000];\r
+                               lineStack = new Line[10000];\r
+                               rectStack = new Rectangle[10000];\r
+                               for (int i = 0; i < 10000; i++)\r
+                               {\r
+                                       lineStack[i] = new Line(0,0,0,0);\r
+                                       rectStack[i] = new Rectangle();\r
+                               }\r
                        }\r
 \r
                        public void clear()\r
@@ -41,32 +56,34 @@ namespace Psychlops
 \r
                        public virtual void line(Line drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.clone());\r
                        }\r
 \r
                        public virtual void rect(Rectangle drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+                               //stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.copyToStack(this));\r
+                               drawee.copyToStack(this);\r
                        }\r
 \r
                        public virtual void ellipse(Ellipse drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.clone());\r
                        }\r
 \r
                        public virtual void polygon(Polygon drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.clone());\r
                        }\r
 \r
                        public virtual void letters(Letters drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.clone());\r
                        }\r
 \r
                        public virtual void image(Image drawee)\r
                        {\r
-                               stack.Enqueue(drawee.clone());\r
+//                             stack.Enqueue(drawee.clone());\r
                        }\r
 \r
                        public void msg(string str, double x, double y) { msg(str, x, y, Color.white); }\r
@@ -88,6 +105,16 @@ namespace Psychlops
        public class Canvas : Templates.StackableDrawable\r
        {\r
 \r
+               internal System.Windows.Controls.Canvas masterPool, prevPool;\r
+               internal System.Windows.Point[] pointPool;\r
+               internal int pointPoolN;\r
+               internal SolidColorBrush[] brushPool;\r
+               internal int brushPoolN;\r
+               internal System.Windows.Shapes.Line[] linePool;\r
+               internal int linePoolN;\r
+               internal System.Windows.Shapes.Rectangle[] rectPool;\r
+               internal int rectPoolN;\r
+\r
                #region initializer\r
 \r
                internal delegate void TwoIntProcedure(int x, int y);\r
@@ -119,7 +146,6 @@ namespace Psychlops
                }\r
                protected void initialize(int wid, int hei)\r
                {\r
-\r
                        width_ = wid;\r
                        height_ = hei;\r
                        api_canvas.Dispatcher.BeginInvoke(new TwoIntProcedure(initialize__), wid, hei);\r
@@ -147,6 +173,28 @@ namespace Psychlops
                        htmlHost.SetStyleAttribute("width", (wid).ToString()+"px");\r
                        htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px");\r
                        htmlHost.SetStyleAttribute("margin", "2em auto auto auto");\r
+\r
+\r
+                       pointPool = new System.Windows.Point[10000];\r
+                       brushPool = new SolidColorBrush[10000];\r
+                       linePool = new System.Windows.Shapes.Line[10000];\r
+                       rectPool = new System.Windows.Shapes.Rectangle[10000];\r
+                       for (int i = 0; i < 10000; i++)\r
+                       {\r
+                               pointPool[i] = new System.Windows.Point();\r
+                               brushPool[i] = new SolidColorBrush();\r
+                               linePool[i] = new System.Windows.Shapes.Line();\r
+                               rectPool[i] = new System.Windows.Shapes.Rectangle();\r
+                       }\r
+                       for (int i = 0; i < 300; i++)\r
+                       {\r
+                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
+                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
+                       }\r
+\r
+                       masterPool = new System.Windows.Controls.Canvas();\r
+                       prevPool = new System.Windows.Controls.Canvas();\r
+//                     masterPool.Children.Add()\r
                }\r
 \r
                #endregion\r
@@ -183,6 +231,8 @@ namespace Psychlops
                public override void clear(Color col)\r
                {\r
                        back_panel.fill = col;\r
+//                     stack.Clear();\r
+                       stackN = 0;\r
                        rect(back_panel);\r
                }\r
 \r
@@ -197,6 +247,12 @@ namespace Psychlops
                                nextIntervalFrame = 1;\r
                                chacked = 1;\r
                        }\r
+//                     pointPoolN = 0;\r
+//                     brushPoolN = 0;\r
+//                     linePoolN = 0;\r
+                       rectPoolN = 0;\r
+                       lineStackN = 0;\r
+                       rectStackN = 0;\r
                        Internal.Main.canvas_flag.WaitOne();\r
                }\r
                public void executeFlip()\r
@@ -207,25 +263,36 @@ namespace Psychlops
                        }\r
                        if (nextIntervalFrame <= 0)\r
                        {\r
+                               var rr = new Random();\r
                                //Psychlops.AppState.statusBar = chacked.ToString();\r
                                if (chacked > 0)\r
                                {\r
-                                       var tmp = new System.Windows.Controls.Canvas();\r
-                                       if (stack.Count > 0)\r
+               //                      prevPool.Children.Clear();\r
+               //                      var tmp = new System.Windows.Controls.Canvas();\r
+//                                     if (stack.Count > 0)\r
+                                       if (stackN > 0)\r
                                        {\r
-                                               foreach (Internal.PrimitiveFigure f in stack)\r
+//                                             foreach (Internal.PrimitiveFigure f in stack)\r
+                                               for (int i = 0; i < stackN - 2; i++ )\r
                                                {\r
-                                                       tmp.Children.Add(f.toNative());\r
+                                                       //                                                      tmp.Children.Add(f.toNative());\r
+//                                                     tmp.Children.Add(f.poolNative(this));\r
+               //                                      tmp.Children.Add(stack[i].poolNative(this));\r
+                                                       System.Windows.Controls.Canvas.SetLeft(api_canvas.Children[i + 1], rectStack[i].left);\r
+                                                       api_canvas.Children[0] = api_canvas.Children[0];\r
                                                }\r
+                                               stackN = 0;\r
+\r
                                        }\r
-                                       api_canvas.Children.Clear();\r
-                                       api_canvas.Children.Add(tmp);\r
-                                       stack.Clear();\r
+               //                      api_canvas.Children.Clear();\r
+               //                      api_canvas.Children.Add(tmp);\r
+//                                     stack.Clear();\r
                                        lock (this)\r
                                        {\r
                                                chacked = 0;\r
                                        }\r
                                        Psychlops.Internal.Main.canvas_flag.Set();\r
+               //                      prevPool = tmp;\r
                                }\r
                        }\r
                        System.Threading.Thread.Sleep(0);\r
@@ -304,6 +371,22 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+                       var tmp = d.linePool[d.linePoolN];\r
+                       tmp.X1 = begin.x;\r
+                       tmp.Y1 = begin.y;\r
+                       tmp.X2 = end.x;\r
+                       tmp.Y2 = end.y;\r
+                       if (stroke.thick == 0.0) tmp.Stroke = fill;\r
+                       else stroke.apply(tmp);\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.linePoolN++;\r
+                       return tmp;\r
+               }\r
        }\r
 \r
        partial class Rectangle\r
@@ -316,6 +399,16 @@ namespace Psychlops
                {\r
                        return (Rectangle)MemberwiseClone();\r
                }\r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+                       var tmp = d.rectStack[d.rectStackN];\r
+                       tmp.v1 = v1;\r
+                       tmp.v2 = v2;\r
+                       tmp.fill = fill;\r
+                       d.stack[d.stackN] = tmp; \r
+                       d.rectStackN++;\r
+                       d.stackN++;\r
+               }\r
                public static implicit operator System.Windows.Rect(Rectangle d)\r
                {\r
                        return new System.Windows.Rect(d.v1.x, d.v1.y, d.v2.x, d.v2.y);\r
@@ -329,6 +422,19 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+                       var tmp = d.rectPool[d.rectPoolN];\r
+                       tmp.Width = width;\r
+                       tmp.Height = height;\r
+                       tmp.Fill = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.rectPoolN++;\r
+                       return tmp;\r
+               }\r
        }\r
 \r
        partial class Ellipse\r
@@ -350,6 +456,20 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+/*                     var tmp = d.rectPool[d.rectPoolN];\r
+                       tmp.Width = width;\r
+                       tmp.Height = height;\r
+                       tmp.Fill = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.rectPoolN++;\r
+*/\r
+                       return this;\r
+               }\r
        }\r
 \r
        partial class Polygon\r
@@ -375,6 +495,21 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+                       /*                      var tmp = d.rectPool[d.rectPoolN];\r
+                                               tmp.Width = width;\r
+                                               tmp.Height = height;\r
+                                               tmp.Fill = fill;\r
+                                               System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                                               System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
+                                               tmp.Visibility = Visibility.Visible;\r
+                                               d.rectPoolN++;\r
+*/\r
+                       return this;\r
+               }\r
+\r
        }\r
        \r
        partial class Letters\r
@@ -431,6 +566,20 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+                       /*                      var tmp = d.rectPool[d.rectPoolN];\r
+                                               tmp.Width = width;\r
+                                               tmp.Height = height;\r
+                                               tmp.Fill = fill;\r
+                                               System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                                               System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
+                                               tmp.Visibility = Visibility.Visible;\r
+                                               d.rectPoolN++;\r
+*/\r
+                       return this;\r
+               }\r
        }\r
 \r
        partial class Image\r
@@ -478,6 +627,21 @@ namespace Psychlops
                        return tmp;\r
                }\r
                public UIElement toNative() { return this; }\r
+\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+                       /*                      var tmp = d.rectPool[d.rectPoolN];\r
+                                               tmp.Width = width;\r
+                                               tmp.Height = height;\r
+                                               tmp.Fill = fill;\r
+                                               System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                                               System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
+                                               tmp.Visibility = Visibility.Visible;\r
+                                               d.rectPoolN++;\r
+*/\r
+                       return this;\r
+               }\r
+\r
        }\r
 \r
        #endregion\r
index 6fc1f15..85c49aa 100644 (file)
@@ -138,6 +138,7 @@ namespace Psychlops
                public interface PrimitiveFigure : Figure\r
                {\r
                        UIElement toNative();\r
+                       UIElement poolNative(Canvas c);\r
                }\r
        }\r
 }
\ No newline at end of file
index d6ec793..9cebe91 100644 (file)
@@ -74,15 +74,17 @@ namespace Psychlops{
                {\r
                        set(v1, v2);\r
                }\r
-               public void set(double x1, double y1, double x2, double y2)\r
+               public Line set(double x1, double y1, double x2, double y2)\r
                {\r
                        begin.set(x1, y1);\r
                        end.set(x2, y2);\r
+                       return this;\r
                }\r
-               public void set(Point v1, Point v2)\r
+               public Line set(Point v1, Point v2)\r
                {\r
                        begin = v1;\r
                        end   = v2;\r
+                       return this;\r
                }\r
 \r
                public Figure shift(Point p)\r
@@ -101,7 +103,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.line(this);\r
                }\r
@@ -200,7 +202,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.rect(this);\r
                }\r
@@ -304,6 +306,13 @@ namespace Psychlops{
                        ydiameter = hei;\r
                        return this;\r
                }\r
+               public Ellipse resize(double width, double height)\r
+               {\r
+                       Point po = center;\r
+                       set(width, height);\r
+                       centering(po);\r
+                       return this;\r
+               }\r
                public Figure shift(Point p)\r
                {\r
                        datum += p;\r
@@ -315,7 +324,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.ellipse(this);\r
                }\r
@@ -387,7 +396,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.polygon(this);\r
                }\r
diff --git a/dev4/psychlops/extention/experiments/experiments.cs b/dev4/psychlops/extention/experiments/experiments.cs
new file mode 100644 (file)
index 0000000..0192688
--- /dev/null
@@ -0,0 +1,4 @@
+namespace Psychlops\r
+{\r
+\r
+}\r
diff --git a/dev4/psychlops/extention/math/probit.cs b/dev4/psychlops/extention/math/probit.cs
new file mode 100644 (file)
index 0000000..0659e6e
--- /dev/null
@@ -0,0 +1,38 @@
+/*\r
+ * http://crsouza.blogspot.com/2010/02/logistic-regression-in-c.html\r
+ * \r
+       Copyright (c) 2009, César Roberto de Souza <cesarsouza@gmail.com>\r
+       All rights reserved.\r
+\r
+       Redistribution and use in source and binary forms, with or without\r
+       modification, are permitted provided that the following conditions are met:\r
+               * Redistributions of source code must retain the above copyright\r
+                 notice, this list of conditions and the following disclaimer.\r
+               * Redistributions in binary form must reproduce the above copyright\r
+                 notice, this list of conditions and the following disclaimer in the\r
+                 documentation and/or other materials provided with the distribution.\r
+               * Neither the name of the software author(s) nor the\r
+                 names of its contributors may be used to endorse or promote products\r
+                 derived from this software without specific prior written permission.\r
+\r
+       THIS SOFTWARE IS PROVIDED BY THE SOFTWARE AUTHOR(S) ''AS IS'' AND ANY\r
+       EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+       DISCLAIMED. IN NO EVENT SHALL THE SOFTWARE AUTHOR(S) BE LIABLE FOR ANY\r
+       DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+       (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+       LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+       ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+       SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE./// <summary>\r
+*/\r
+\r
+namespace Psychlops\r
+{\r
+\r
+       public class LogisticRegression\r
+       {\r
+\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/dev4/psychlops/extention/media/dom.cs b/dev4/psychlops/extention/media/dom.cs
new file mode 100644 (file)
index 0000000..a733682
--- /dev/null
@@ -0,0 +1,6 @@
+\r
+namespace Psychlops\r
+{\r
+\r
+\r
+}
\ No newline at end of file
index f53bc0c..ba41041 100644 (file)
@@ -77,6 +77,7 @@
     <Compile Include="App.xaml.cs">\r
       <DependentUpon>App.xaml</DependentUpon>\r
     </Compile>\r
+    <Compile Include="Store.cs" />\r
     <Compile Include="PsychlopsMain.cs" />\r
     <Compile Include="MainPage.xaml.cs">\r
       <DependentUpon>MainPage.xaml</DependentUpon>\r
diff --git a/test4/Store.cs b/test4/Store.cs
new file mode 100644 (file)
index 0000000..bff2e6d
--- /dev/null
@@ -0,0 +1,254 @@
+/*\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+       public class PsychlopsMain\r
+       {\r
+               public void psychlops_main()\r
+               {\r
+                       Canvas window = new Canvas(300, 300);\r
+\r
+                       var figure_r = new Rectangle();\r
+                       var figure_e = new Ellipse();\r
+                       figure_r.set(100,100).centering().shift(0, 0);\r
+                       figure_e.set(100,100).centering().shift(0, 0);\r
+\r
+                       while (!Keyboard.esc.pushed())\r
+                       {\r
+                               figure_r.fill = new Color(0, 0, 1);\r
+                               figure_r.centering(new Point(100,100)).draw();\r
+                               figure_e.fill = new Color(1, 0, 0);\r
+                               figure_e.centering(new Point(100, 100)).draw();\r
+                               window.flip();\r
+                       }\r
+               }\r
+       }\r
+\r
+}\r
+\r
+/*\r
+\r
+\r
+\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+       public class PsychlopsMain\r
+       {\r
+               public void psychlops_main()\r
+               {\r
+                       var figure_type = 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 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
+                       Canvas window = new Canvas(300, 300);\r
+\r
+                       var figure_r = new Rectangle();\r
+                       var figure_e = new Ellipse();\r
+                       figure_r.centering().shift(0, 0);\r
+                       figure_e.centering().shift(0, 0);\r
+\r
+                       int frame = 0;\r
+                       int direction = 1, motion_dir = 1;\r
+\r
+                       while (!Keyboard.esc.pushed())\r
+                       {\r
+                               window.clear();\r
+\r
+                               if (frame % 30 == 0)\r
+                               {\r
+                                       direction = direction * -1;\r
+\r
+                               }\r
+\r
+                               if (frame % 90 == 0)\r
+                               {\r
+                                       motion_dir *= -1;\r
+                               }\r
+\r
+                               figure_r.resize(figure_r.getWidth() + direction * 1, figure_r.getHeight() + direction * 1);\r
+                               figure_r.shift(motion_dir * 1, 0);\r
+                               figure_r.fill = new Color(color_r, color_g, color_b);\r
+\r
+                               figure_e.resize(figure_e.getWidth() + direction * 1, figure_e.getHeight() + direction * 1);\r
+                               figure_e.shift(motion_dir * 1, 0);\r
+                               figure_e.fill = new Color(color_r, color_g, color_b);\r
+\r
+                               if (System.String.Compare(figure_type, "Rectangle") == 0)\r
+                               {\r
+                                       figure_r.draw();\r
+                               }\r
+                               else\r
+                               {\r
+                                       figure_e.draw();\r
+                               }\r
+\r
+\r
+                               frame++;\r
+\r
+\r
+                               window.flip();\r
+                       }\r
+               }\r
+       }\r
+\r
+}\r
+ * */\r
+\r
+\r
+/*\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+       public class PsychlopsMain\r
+       {\r
+               public void psychlops_main()\r
+               {\r
+                       var figure_type = 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
+                       Canvas window = new Canvas(300, 300);\r
+\r
+                       var figure_r = new Rectangle();\r
+                       var figure_e = new Ellipse();\r
+                       Shape figure = figure_r;\r
+                       \r
+                       while (!Keyboard.esc.pushed())\r
+                       {\r
+                               if (System.String.Compare(figure_type, "Rectangle") == 0)\r
+                               {\r
+                                       figure_r.set(size_x, size_y);\r
+                                       figure = figure_r;\r
+                               }\r
+                               else\r
+                               {\r
+                                       figure_e.set(size_x, size_y);\r
+                                       figure = figure_e;\r
+                               }\r
+                               figure.fill = new Color(color_r, color_g, color_b);\r
+\r
+                               window.clear(Color.black);\r
+                               figure.centering().shift(shift_x, shift_y).draw();\r
+                               window.flip();\r
+                       }\r
+               }\r
+       }\r
+\r
+}\r
+*/\r
+\r
+\r
+/*\r
+using Psychlops;\r
+\r
+namespace Psychlops\r
+{\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
+       }\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