+/*\r
+// Lilac Chaser.\r
+// Zaidi Q, Ennis R, Cao D, Lee B (2012)\r
+// Neural locus of color after-image.\r
+// Current Biology, 22, 220-224\r
+///+ Prefix\r
+//// Include Psychlops Package\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlightApp\r
+{\r
+\r
+ public class PsychlopsMain\r
+ {\r
+///- Prefix\r
+\r
+\r
+ ///+ Stimulus drawing function\r
+ //// A function for stimulus drawing (main body)\r
+ public void psychlops_main() {\r
+\r
+ ///+ Preperation\r
+ //// Declare and initialize local variables\r
+ Canvas cnvs = new Canvas(Canvas.window); //Prepare drawing window\r
+ double dotsize = 100;\r
+ double dot_lum = 1;\r
+ double bg_lum = 0.5;\r
+ double duration = 8.0;\r
+ int stroke = 0;\r
+ bool draw_base_position = false;\r
+\r
+ var fixate = new Rectangle();\r
+ Image dot = new Image();\r
+ Color col = new Color();\r
+ double xp, yp, radius, a;\r
+\r
+ Psychlops.Widgets.Slider hue, value;\r
+ ///- Preperation\r
+\r
+ ///+ set Independent\r
+ //// set variables and value ranges for interaction\r
+ Interval rng = new Interval();\r
+ hue = new Psychlops.Widgets.Slider("Hue", 0.0 <= rng < 360.0, 1, 12);\r
+ hue.setValue(300.0);\r
+ value = new Psychlops.Widgets.Slider("Lightness", 0 <= rng <= 1.0, 0.1, 0.05);\r
+ value.setValue(0.7);\r
+ ///- set Independent\r
+\r
+ dot.set(dotsize, dotsize);\r
+ double width = dotsize, height = dotsize, sigma = (width / 6.0);\r
+\r
+ fixate.set(11,11);\r
+\r
+ int frame = 0;\r
+\r
+ while (!Keyboard.esc.pushed())\r
+ {\r
+ ///+ reflesh dot\r
+ if (hue.changed)\r
+ {\r
+ Psychlops.ColorSpaces.HSV hsv = new Psychlops.ColorSpaces.HSV();\r
+ hsv.H = Math.mod( hue.getValue(), 360);\r
+ hsv.S = 1.0;\r
+ hsv.V = value.getValue();\r
+ dot.each((x, y) =>\r
+ {\r
+ yp = y - height / 2.0;\r
+ xp = x - width / 2.0;\r
+ radius = Math.sqrt(xp * xp + yp * yp);\r
+ hsv.A = Math.exp(-(radius * radius) / (2.0 * sigma * sigma));\r
+ return hsv.toRGB();\r
+ });\r
+ }\r
+ ///+ reflesh dot\r
+\r
+\r
+ ///+ stroke count\r
+ if(frame%((int)duration)==0) {\r
+ stroke++; stroke %= 8;\r
+ }\r
+ ///- stroke count\r
+\r
+ cnvs.clear(new Color(bg_lum)); //Clear window\r
+\r
+\r
+ ///+ Draw dots\r
+ //// Draw dots at a desinated position.\r
+ for(int i=0; i<8; i++) {\r
+ if(i!=stroke) {\r
+ dot.centering().shift(dotsize*1.3*Math.cos(i/8.0*2*Math.PI), dotsize*1.3*Math.sin(i/8.0*2*Math.PI)).draw();\r
+ }\r
+ }\r
+ ///- Draw dots\r
+\r
+ fixate.centering().draw();\r
+\r
+ cnvs.flip(); // Flip frame buffers\r
+ frame++;\r
+ }\r
+\r
+ }\r
+ ///- Stimulus drawing function\r
+\r
+ }\r
+\r
+}\r
+*/\r
+\r
+\r
+// Motion with glass patterns.\r