OSDN Git Service

faster2
authorunknown <hskwk@.(none)>
Wed, 4 Aug 2010 06:24:58 +0000 (15:24 +0900)
committerunknown <hskwk@.(none)>
Wed, 4 Aug 2010 06:24:58 +0000 (15:24 +0900)
PsychlopsSilverlight4Dev.sln
dev4/psychlops/core/graphic/canvas.cs
dev4/psychlops/core/graphic/image.cs
dev4/psychlops/core/math/util.cs
dev4/psychlops/extention/experiments/experiments.cs
test4/PsychlopsMain.cs

index bec6cfd..8a731bd 100644 (file)
@@ -1,8 +1,6 @@
 \r
 Microsoft Visual Studio Solution File, Format Version 11.00\r
 # Visual Web Developer Express 2010\r
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PsychlopsSilverlight4", "dev4\PsychlopsSilverlight4.csproj", "{58F3CEF1-8123-4105-9525-B7E2C7F188AC}"\r
-EndProject\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PsychlopsSilverlight4test", "test4\PsychlopsSilverlight4test.csproj", "{46CA4F41-B3F5-43E0-9BC7-DDD7EBF3C1E4}"\r
 EndProject\r
 Global\r
@@ -11,10 +9,6 @@ Global
                Release|Any CPU = Release|Any CPU\r
        EndGlobalSection\r
        GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
-               {58F3CEF1-8123-4105-9525-B7E2C7F188AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
-               {58F3CEF1-8123-4105-9525-B7E2C7F188AC}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
-               {58F3CEF1-8123-4105-9525-B7E2C7F188AC}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
-               {58F3CEF1-8123-4105-9525-B7E2C7F188AC}.Release|Any CPU.Build.0 = Release|Any CPU\r
                {46CA4F41-B3F5-43E0-9BC7-DDD7EBF3C1E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {46CA4F41-B3F5-43E0-9BC7-DDD7EBF3C1E4}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
                {46CA4F41-B3F5-43E0-9BC7-DDD7EBF3C1E4}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
index 7f6360c..6216e53 100644 (file)
@@ -56,7 +56,7 @@ namespace Psychlops
                                {\r
                                        polygonStack[i] = new Polygon();\r
                                        lettersStack[i] = new Letters();\r
-                                       //imageStack[i] = new Image();\r
+                                       imageStack[i] = new Image(1,1);\r
                                }\r
                        }\r
 \r
@@ -75,7 +75,8 @@ namespace Psychlops
 \r
                        public virtual void line(Line drawee)\r
                        {\r
-//                             stack.Enqueue(drawee.clone());\r
+                               //                              stack.Enqueue(drawee.clone());\r
+                               drawee.copyToStack(this);\r
                        }\r
 \r
                        public virtual void rect(Rectangle drawee)\r
@@ -141,6 +142,10 @@ namespace Psychlops
                internal int ellipsePoolN;\r
                internal System.Windows.Shapes.Polygon[] polygonPool;\r
                internal int polygonPoolN;\r
+               internal System.Windows.Controls.TextBlock[] lettersPool;\r
+               internal int lettersPoolN;\r
+               internal System.Windows.Controls.Image[] imagePool;\r
+               internal int imagePoolN;\r
 \r
                #region initializer\r
 \r
@@ -171,11 +176,17 @@ namespace Psychlops
                        api_canvas = apicnvs;\r
                        initialize(wid, hei);\r
                }\r
+\r
+               protected bool AsyncInitBool;\r
                protected void initialize(int wid, int hei)\r
                {\r
+                       AsyncInitBool = false;\r
                        width_ = wid;\r
                        height_ = hei;\r
                        api_canvas.Dispatcher.BeginInvoke(new TwoIntProcedure(initialize__), wid, hei);\r
+                       while(!AsyncInitBool)\r
+                       {\r
+                       }\r
                        Mouse._prime = api_canvas;\r
                        Main.drawable = this;\r
                        Main.canvas = this;\r
@@ -206,22 +217,29 @@ namespace Psychlops
                        brushPool = new SolidColorBrush[10000];\r
                        linePool = new System.Windows.Shapes.Line[10000];\r
                        rectPool = new System.Windows.Shapes.Rectangle[10000];\r
+                       ellipsePool = new System.Windows.Shapes.Ellipse[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
+                               ellipsePool[i] = new System.Windows.Shapes.Ellipse();\r
                        }\r
-                       for (int i = 0; i < 300; i++)\r
+                       polygonPool = new System.Windows.Shapes.Polygon[1000];\r
+                       lettersPool = new System.Windows.Controls.TextBlock[1000];\r
+                       for (int i = 0; i < 1000; i++)\r
                        {\r
-                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
-                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
+                               polygonPool[i] = new System.Windows.Shapes.Polygon();\r
+                               lettersPool[i] = new System.Windows.Controls.TextBlock();\r
                        }\r
 \r
                        masterPool = new System.Windows.Controls.Canvas();\r
                        prevPool = new System.Windows.Controls.Canvas();\r
-//                     masterPool.Children.Add()\r
+                       api_canvas.Children.Add(masterPool);\r
+                       //api_canvas.Children.Remove(Internal.Main.widgetStack);\r
+\r
+                       AsyncInitBool = true;\r
                }\r
 \r
                #endregion\r
@@ -258,78 +276,15 @@ 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
                int nextIntervalFrame = 1, chacked = 0;\r
-               /*\r
-               public void flip()\r
+               public void flip(int n)\r
                {\r
-                       //api_canvas.Dispatcher.BeginInvoke(flipexec);\r
-                       //flipexec();\r
-                       //System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\r
-                       lock (this)\r
-                       {\r
-                               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
+                       flip();\r
                }\r
-               public void executeFlip()\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               nextIntervalFrame--;\r
-                       }\r
-                       if (nextIntervalFrame <= 0)\r
-                       {\r
-                               var rr = new Random();\r
-                               //Psychlops.AppState.statusBar = chacked.ToString();\r
-                               if (chacked > 0)\r
-                               {\r
-               //                      prevPool.Children.Clear();\r
-                                       var tmp = new System.Windows.Controls.Canvas();\r
-                                       if (stack.Count > 0)\r
-               //                      if (stackN > 0)\r
-                                       {\r
-                                               //foreach (UIElement e in api_canvas.Children)\r
-                                               //{\r
-                                               //}\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.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
-                                       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
-               }\r
-               */\r
-\r
                public void flip()\r
                {\r
                        lock (this)\r
@@ -339,10 +294,24 @@ namespace Psychlops
                        }\r
                        //                      pointPoolN = 0;\r
                        //                      brushPoolN = 0;\r
-                       //                      linePoolN = 0;\r
+                       linePoolN = 0;\r
                        rectPoolN = 0;\r
                        lineStackN = 0;\r
                        rectStackN = 0;\r
+                       polygonStackN = 0;\r
+                       ellipseStackN = 0;\r
+                       lettersStackN = 0;\r
+                       imageStackN = 0;\r
+\r
+                       pointPoolN = 0;\r
+                       brushPoolN = 0;\r
+                       linePoolN = 0;\r
+                       rectPoolN = 0;\r
+                       ellipsePoolN = 0;\r
+                       polygonPoolN = 0;\r
+                       lettersPoolN = 0;\r
+                       imagePoolN = 0;\r
+\r
                        Internal.Main.canvas_flag.WaitOne();\r
                }\r
                public void executeFlip()\r
@@ -355,19 +324,15 @@ namespace Psychlops
                        {\r
                                if (chacked > 0)\r
                                {\r
-                                       //api_canvas.Children.Clear();\r
-                                       //var tmp = new System.Windows.Controls.Canvas();\r
+                                       masterPool.Children.Clear();\r
                                        if (stackN > 0)\r
                                        {\r
                                                for (int i = 0; i < stackN - 2; i++)\r
                                                {\r
-                                                       //api_canvas.Children.Add(stack[i].poolNative(this));\r
-                                                       api_canvas.Children.Add(stack[i].poolNative(this));\r
+                                                       masterPool.Children.Add(stack[i].poolNative(this));\r
                                                }\r
                                                stackN = 0;\r
                                        }\r
-                                       //api_canvas.Children.Clear();\r
-                                       //api_canvas.Children.Add(tmp);\r
                                        lock (this)\r
                                        {\r
                                                chacked = 0;\r
@@ -454,6 +419,19 @@ namespace Psychlops
                }\r
                public UIElement toNative() { return this; }\r
 \r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+                       var tmp = d.lineStack[d.lineStackN];\r
+                       tmp.begin.x = begin.x;\r
+                       tmp.begin.y = begin.y;\r
+                       tmp.end.x = end.x;\r
+                       tmp.end.y = end.y;\r
+                       tmp.fill = fill;\r
+                       tmp.stroke = stroke;\r
+                       d.stack[d.stackN] = tmp;\r
+                       d.lineStackN++;\r
+                       d.stackN++;\r
+               }\r
                public UIElement poolNative(Canvas d)\r
                {\r
                        var tmp = d.linePool[d.linePoolN];\r
@@ -548,7 +526,7 @@ namespace Psychlops
                        tmp.ydiameter = ydiameter;\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.ellipseStackN++;\r
                        d.stackN++;\r
                }\r
                public UIElement poolNative(Canvas d)\r
@@ -561,7 +539,7 @@ namespace Psychlops
                        System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
                        tmp.Visibility = Visibility.Visible;\r
                        d.ellipsePoolN++;\r
-                       return this;\r
+                       return tmp;\r
                }\r
        }\r
 \r
@@ -600,20 +578,23 @@ namespace Psychlops
                        }\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.polygonStackN++;\r
                        d.stackN++;\r
                }\r
                public UIElement poolNative(Canvas d)\r
                {\r
                        var tmp = d.polygonPool[d.polygonPoolN];\r
                        tmp.Fill = fill;\r
-                       /*\r
-                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
-                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
-                       */ \r
+                       tmp.Points.Clear();\r
+                       foreach (var v in vertices)\r
+                       {\r
+                               tmp.Points.Add(v);\r
+                       }\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\r
                        tmp.Visibility = Visibility.Visible;\r
                        d.polygonPoolN++;\r
-                       return this;\r
+                       return tmp;\r
                }\r
 \r
        }\r
@@ -675,25 +656,31 @@ namespace Psychlops
 \r
                public void copyToStack(Templates.StackableDrawable d)\r
                {\r
-                       var tmp = d.polygonStack[d.polygonStackN];\r
+                       var tmp = d.lettersStack[d.lettersStackN];\r
+                       tmp.str = str;\r
                        tmp.datum = datum;\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.lettersStackN++;\r
                        d.stackN++;\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
+                       var tmp = d.lettersPool[d.lettersPoolN];\r
+                       tmp.Text = str;\r
+                       tmp.Width = 500;\r
+                       tmp.Height = 500;\r
+                       tmp.FontSize = font.size;\r
+                       //tmp.FontFamily = ,\r
+                       tmp.FontStyle = FONT_STYLE_BRIDGE[font.style];\r
+                       tmp.FontWeight = FONT_WEIGHT_BRIDGE[font.weight];\r
+                       tmp.TextAlignment = LETTERS_H_ALIGN_BRIDGE[align];\r
+                       tmp.Foreground = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.lettersPoolN++;\r
+                       return tmp;\r
                }\r
        }\r
 \r
@@ -707,6 +694,7 @@ namespace Psychlops
                internal void create__(int wid, int hei)\r
                {\r
                        buffer = new WriteableBitmap(wid, hei);\r
+                       AsyncBool = true;\r
                }\r
                delegate void FieldFunc1(System.Func<int, int, System.Windows.Media.Color> func);\r
                delegate void FieldFunc2(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func);\r
@@ -743,17 +731,24 @@ namespace Psychlops
                }\r
                public UIElement toNative() { return this; }\r
 \r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+                       var tmp = d.imageStack[d.imageStackN];\r
+                       tmp.datum = datum;\r
+                       tmp.buffer = buffer;\r
+                       tmp.self_rect = self_rect;\r
+                       d.stack[d.stackN] = tmp;\r
+                       d.imageStackN++;\r
+                       d.stackN++;\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
+                       var tmp = d.imagePool[d.imagePoolN];\r
+                       tmp.Source = buffer;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.rectPoolN++;\r
                        return this;\r
                }\r
 \r
index c3df14e..6d5f3f5 100644 (file)
@@ -19,19 +19,16 @@ namespace Psychlops{
                public Point getDatum() { return datum; }\r
                public Point setDatum(Point p) { datum = p; return datum; }\r
                public Rectangle self_rect;\r
+               protected bool AsyncBool;\r
 \r
                public Image(int wid, int hei)\r
                {\r
+                       AsyncBool = false;\r
                        initialize__(wid, hei);\r
                        self_rect = new Rectangle(wid, hei);\r
+                       while (!AsyncBool) { }\r
                }\r
 \r
-               /*public Image shift(double x, double y)\r
-               {\r
-                       datum.x += x;\r
-                       datum.y += y;\r
-                       return this;\r
-               }*/\r
                public Figure shift(Point p)\r
                {\r
                        datum = datum + p;\r
index 7f498d3..85134a9 100644 (file)
@@ -5,13 +5,38 @@ namespace Psychlops
 \r
        public static class Math\r
        {\r
-               public static readonly double PI = 3.14159265, E = 2.718281828459045;\r
+               public static readonly double PI = 3.14159265, E = 2.718281828459045, LOG2E = 1.44269504088896340736;\r
                public static Random random_generator;\r
                static Math()\r
                {\r
                        random_generator = new Random();\r
                }\r
 \r
+               public static double max(double val1, double val2)\r
+               {\r
+                       return val1 > val2 ? val1 : val2;\r
+               }\r
+               public static double min(double val1, double val2)\r
+               {\r
+                       return val1 < val2 ? val1 : val2;\r
+               }\r
+               public static void shuffle<X>(X[] array, int n)\r
+               {\r
+                       int a;\r
+                       X tmp;\r
+                       for(int i = 1; i < n; i++){\r
+                               a = random(i + 1);\r
+                               tmp = array[i];\r
+                               array[i] = array[a];\r
+                               array[a] = tmp;\r
+                       }\r
+               }\r
+\r
+\r
+               public static double mod(double lhs, double rhs)\r
+               {\r
+                       return lhs - System.Math.Floor(lhs/rhs)*rhs;\r
+               }\r
                public static double abs(double x)\r
                {\r
                        return System.Math.Abs(x);\r
@@ -40,6 +65,16 @@ namespace Psychlops
                {\r
                        return System.Math.Log(x);\r
                }\r
+               public static double log2(double val)\r
+               {\r
+                       return log(val) * LOG2E;\r
+               }\r
+               /*public static int round(double val)\r
+               {\r
+                       double integer_part, particle = modf(val, &integer_part);\r
+                       return ((particle < 0.5 | (particle == 0.5 && (int)integer_part % 2 == 0)) ? (int)integer_part : (int)integer_part + 1);\r
+               }*/\r
+\r
                public static double radius(double x, double y)\r
                {\r
                        return System.Math.Sqrt(x * x + y * y);\r
@@ -49,6 +84,10 @@ namespace Psychlops
                {\r
                        return (random_generator.NextDouble());\r
                }\r
+               public static int random(int x)\r
+               {\r
+                       return (int)((random_generator.NextDouble()) * x);\r
+               }\r
                public static double random(double x)\r
                {\r
                        return (random_generator.NextDouble()) * x;\r
index 0192688..9a1aaf0 100644 (file)
@@ -1,4 +1,17 @@
 namespace Psychlops\r
 {\r
+/*\r
+       public class Independent\r
+       {\r
+               public double value;\r
 \r
+               public Independent()\r
+               {\r
+                       value = 0;\r
+               }\r
+\r
+\r
+               public static implicit operator double(Independent i) { return i.value; }\r
+       }\r
+       */\r
 }\r
index b9daaa9..7461d42 100644 (file)
@@ -1,4 +1,137 @@
-\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+\r
+       public class PsychlopsMain\r
+       {\r
+\r
+               Canvas cnvs;\r
+               int i;\r
+               object xxx;\r
+               double x, y, z, t, p, temp, xx, yy;\r
+\r
+               //Set Target Initial Value\r
+               double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;\r
+\r
+               //Set Background Initial Value\r
+               double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
+               Psychlops.Widgets.Slider DotNumberS;\r
+\r
+               public void psychlops_main()\r
+               {\r
+                       DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500));\r
+                       //Independent ind = new Independent();\r
+\r
+                       cnvs = new Canvas(500, 500);\r
+                       xxx = 1;\r
+                       Image img = new Image(100,100);\r
+                       for (int x = 0; x < 100; x++)\r
+                       {\r
+                               for (int y = 0; y < 100; y++)\r
+                               {\r
+                                       img.pix(x,y, new Color( Math.sin(x+y))  );\r
+                               }\r
+                       }\r
+\r
+\r
+                       //Declare background dots and target\r
+                       Rectangle[] BGDot = new Rectangle[2048];\r
+                       for(int i=0; i<2048; i++){\r
+                       BGDot[i]=new Rectangle();\r
+                       }\r
+                       Rectangle[] Target= new Rectangle[10];\r
+                       for(int i=0; i<10; i++){\r
+                       Target[i]=new Rectangle();\r
+                       }\r
+\r
+\r
+                       //Declare Matrix to keep back ground dots' coordinate value\r
+                       double[] DotX=new double[2048];\r
+                       double[] DotY = new double[2048];\r
+\r
+\r
+\r
+                       //Set Independent variables to manipulate\r
+\r
+\r
+                       //Initialize positions of background dots\r
+                       for(int i=0; i<2048; i++){\r
+                       t=2.0*Math.PI*Math.random(1.0);\r
+                       p=2.0*Math.PI*Math.random(1.0);\r
+                       DotX[i]=t;\r
+                       DotY[i]=p;\r
+\r
+                       x=BGRadii*Math.cos(t)*Math.cos(p);\r
+                       y=BGRadii*Math.sin(t)*Math.cos(p);\r
+                       BGDot[i].set(BGSize, BGSize);\r
+                       BGDot[i].centering().shift(x,y);\r
+                       }\r
+\r
+                       //Initialize positions of targets\r
+                       for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
+\r
+                       double COS, SIN;\r
+\r
+                       //Main stimulus loop\r
+                       while(true){\r
+                       //Clear the main window\r
+                       cnvs.clear(Color.black);\r
+\r
+\r
+                       temp=Axis/360*2*Math.PI;\r
+                       COS=Math.cos(temp);\r
+                       SIN=Math.sin(temp);\r
+\r
+                       //Calculate positions of background dots and set them\r
+                       for(int i=0; i<DotNumber; i++){\r
+                       //Calculate in polar coordinate\r
+                       t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;\r
+                       p=DotY[i];\r
+\r
+                       //Save current position\r
+                       DotX[i]=t;\r
+\r
+                       //Convert to Decartes coordinate\r
+                       x=BGRadii*Math.cos(t)*Math.cos(p);\r
+                       y=BGRadii*Math.sin(t)*Math.cos(p);\r
+                       z=BGRadii*Math.sin(p);\r
+                       xx=x;\r
+                       yy=SIN*y+COS*z;\r
+\r
+                       //Set Dotsize and Draw them\r
+                       BGDot[i].set(BGSize, BGSize);\r
+                       BGDot[i].centering().shift(xx,yy);\r
+                       BGDot[i].draw( Color.blue);\r
+                       }\r
+\r
+                       //Calculate positions of targets and set them\r
+                       temp=Rotate*2*Math.PI/360.0;\r
+                       cnvs.msg(TargetNumber.ToString(), 0, 30);\r
+                       for (int i = 0; i < 5; i++)\r
+                       {\r
+                               cnvs.msg(i.ToString(), 50+50*i, 30);\r
+                               t = 2.0 * Math.PI/TargetNumber;\r
+                               x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp);\r
+                               y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp);\r
+                               Target[i].centering().shift(x,y);\r
+                               Target[i].fill = Color.yellow;\r
+                               Target[i].draw();\r
+                       }\r
+\r
+//                     img.centering().draw();\r
+                       //Reflect drawing at the next frame;\r
+                       cnvs.flip();\r
+               }\r
+\r
+\r
+\r
+               }\r
+       }\r
+\r
+}\r
+\r
+\r
 /*\r
 using Psychlops;\r
 \r
@@ -48,6 +181,9 @@ namespace PsychlopsSilverlight4test
 \r
 */\r
 \r
+/*\r
+\r
+\r
 using Psychlops;\r
 \r
 namespace Psychlops\r
@@ -150,6 +286,7 @@ namespace PsychlopsSilverlight4test
        }\r
 \r
 }\r
-\r
+ * \r
+ * */\r
 \r
 \r