OSDN Git Service

silverlight5
[psychlops/silverlight.git] / test4 / PsychlopsMain.cs
diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs
deleted file mode 100644 (file)
index e69a680..0000000
+++ /dev/null
@@ -1,756 +0,0 @@
-using Psychlops;\r
-\r
-namespace PsychlopsSilverlightApp\r
-{\r
-\r
-       public class PsychlopsMain\r
-       {\r
-\r
-\r
-               public void psychlops_main() {\r
-\r
-       Canvas display = new Canvas(768,768);\r
-\r
-       double rect_size = 100;\r
-       double rect_lum  = 0.5;\r
-       double bg_lum    = 0.5;\r
-       double size = 250.0;\r
-   double sigma;\r
-   sigma = size/6.0;\r
-   double lambda;\r
-   lambda = 6*sigma;\r
-   int envelopemode = 0;\r
-   double refresh = display.getRefreshRate();\r
-   double[] SF=new double[2];\r
-\r
-   SF[0]=4.0;\r
-   SF[1]=4.0;\r
-\r
-   double phase=0;\r
-\r
-   double[] initphase = new double[2];\r
-   double _i, _j, _x, _y, _x2, _y2, col;\r
-   double amplitude = 1.0;\r
-\r
-       Rectangle fixation1 = new Rectangle(3,9);\r
-   Rectangle fixation2 = new Rectangle(9,3);\r
-       fixation1.centering();\r
-       fixation2.centering();\r
-   Rectangle contrastrect = new Rectangle();\r
-   contrastrect.set(760,760);\r
-\r
-   Image envelope = new Image();\r
-   Psychlops.Color bglum= new Color(0.5,0.5,0.5);\r
-   Psychlops.Color masklum = new Color(0.5,0.5,0.5,0.5);\r
-\r
-       Interval rng = new Interval();\r
-\r
-\r
-       Psychlops.Widgets.Slider TF;\r
-       TF = new Psychlops.Widgets.Slider("TF", 0.25<=rng<=2.0 , 0.1);\r
-   TF.value=0.75;\r
-\r
-\r
-\r
-       Psychlops.Widgets.Slider SFs;\r
-       SFs = new Psychlops.Widgets.Slider("SF", 4.0<=rng<=16.0 ,  4.0);\r
-       SFs.value = 4.0;\r
-\r
-   Psychlops.Widgets.Slider contrast;\r
-       contrast= new Psychlops.Widgets.Slider("Contrast", 0.0<=rng<=1.0 ,  0.1);\r
-       contrast.value = 0.1;\r
-\r
-\r
-       var element =  StaticFunctions.NewArray<Figures.ShaderGabor>(2);\r
-    for (int i = 0; i < element.Length; i++){\r
-           element[i].setSigma(sigma); // set a size of patch as a halfwidth of Gaussian\r
-           element[i].orientation = Math.PI/4.0+Math.PI/2.0*(1-i);//Math.PI/2*(rand()%2);// //set orientations\r
-           initphase[i]=0;\r
-  }\r
-\r
-\r
-\r
-      envelope.set(size, size);\r
-      envelope.clear(bglum);\r
-\r
-   for(int i=0; i<size; i++){\r
-       for(int j=0; j<size; j++){\r
-           _i=i-size*0.5;\r
-           _j=j-size*0.5;\r
-           _x=_i*Math.cos(-Math.PI/4.0)+_j*Math.sin(-Math.PI/4.0);\r
-           _y=-_i*Math.sin(-Math.PI/4.0)+_j*Math.cos(-Math.PI/4.0);\r
-           col=Math.exp(-(_x*_x)/(2*Math.pow(sigma*2/6.0,2.0))-(_y*_y)/(2*Math.pow(sigma*2,2.0)));\r
-           envelope.alpha(i,j,1.0-col);\r
-\r
-           }\r
-       }\r
-\r
-\r
-       while(!Keyboard.esc.pushed()) {\r
-           if(Keyboard.spc.pushed())envelopemode++; envelopemode%=2;\r
-       Display.clear(bglum);\r
-       phase ++;\r
-       //phase = fmod(phase,60);\r
-\r
-       for(int i=0; i<2; i++) {\r
-           element[i].phase =(SF[i]/SF[0])*amplitude*\r
-Math.PI*Math.sin(Math.PI/2*i+2*Math.PI*phase*TF/refresh);\r
-           element[i].wavelength = lambda/SF[i];\r
-           element[i].contrast = contrast;\r
-       }\r
-\r
-\r
-       element[0].centering().shift(-size * 0.6, -size * 0.6);\r
-       element[0].draw();\r
-       element[1].centering().shift(size*0.6,-size*0.6);\r
-       element[1].draw();\r
-               element[1].centering().shift(-size*0.6,size*0.6);\r
-       element[1].draw();\r
-               element[0].centering().shift(size*0.6,size*0.6);\r
-       element[0].draw();\r
-\r
-\r
-               if(envelopemode>0){\r
-                   envelope.centering().shift(size*0.6,-size*0.6).draw();\r
-                   envelope.centering().shift(-size*0.6,size*0.6).draw();\r
-                   }\r
-       masklum.set(bg_lum, bg_lum, bg_lum, 1-contrast);\r
-       contrastrect.centering();\r
-       contrastrect.draw(masklum);\r
-       fixation1.centering().shift(size*2,0.0);\r
-       fixation1.draw(Color.red);\r
-       fixation2.centering().shift(size*2,0.0);\r
-       fixation2.draw(Color.red);\r
-\r
-          Display.var(Mouse.x, 300, 300);\r
-          Display.var(Mouse.y, 300, 320);\r
-\r
-               Display.flip();\r
-\r
-\r
-       }\r
-\r
-}\r
-\r
-\r
-\r
-       }\r
-\r
-}\r
-/*\r
-\r
-using Psychlops;\r
-//Position Bias Program\r
-namespace PsychlopsSilverlightApp\r
-{\r
-\r
-       public class PsychlopsMain\r
-       {\r
-               Canvas cnvs;\r
-               Image img, img2, img3;\r
-               int isize = 40;\r
-               int frames;\r
-               Psychlops.Widgets.Slider tfreq;\r
-               Psychlops.Widgets.Slider contrast;\r
-               Psychlops.Widgets.Slider lambda;\r
-\r
-\r
-\r
-               public void psychlops_main()\r
-               {\r
-                       cnvs = new Canvas(300, 600);\r
-                       Interval rng = new Interval();\r
-                       tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0);\r
-                       contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25);\r
-                       lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30);\r
-\r
-                       img = new Image(isize * 2, isize * 2);\r
-                       img2 = new Image(isize * 2, isize * 2);\r
-                       img3 = new Image(isize * 2, isize * 2);\r
-\r
-                       var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100);\r
-                       foreach (var g in gabor1)\r
-                       {\r
-                               g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300);\r
-                               //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300);\r
-                               g.orientation = Math.random(2 * Math.PI);\r
-                               //g.orientation2 = Math.random(2 * Math.PI);\r
-                       }\r
-\r
-                       while (true)\r
-                       {\r
-                               cnvs.clear(new Color(0.5));\r
-\r
-                               Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
-                               Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);\r
-                               Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
-\r
-\r
-                               //img.centering().shift(0, -isize * 1.5).draw();\r
-                               //img2.centering().draw();\r
-                               //img3.centering().shift(0, isize * 1.5).draw();\r
-\r
-\r
-                               //foreach (var g in gabor1)\r
-                               for (int i = 0; i < gabor1.Length; i++)\r
-                               {\r
-                                       gabor1[i].wavelength = lambda;\r
-                                       gabor1[i].phase = (double)frames * 2.0 * Math.PI * tfreq / 60;\r
-                                       gabor1[i].contrast = contrast;\r
-                                       //g.wavelength2 = lambda * 2;\r
-                                       //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60;\r
-                                       //g.contrast2 = contrast / 2;\r
-                                       gabor1[i].draw();\r
-                               }\r
-\r
-                               if (!Mouse.left.pressed()) frames++;\r
-\r
-                               cnvs.flip();\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-\r
-/*\r
-///+ Prefix linkto BasicCode1\r
-//// Lines for set up Psychlops environment\r
-using Psychlops;\r
-\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
-\r
-                       ///+ 0 SetGlobal\r
-                       ////Prepare global parameters\r
-                       Rectangle p1 = new Rectangle(1,1);\r
-                       Color col1 = new Color();\r
-                       double width=50;\r
-                       double height=10;\r
-                       double lambda=60;\r
-                       double lmean=0.25, contrast = 0.5;\r
-                       double x0 = 0;\r
-                       double y0 = 0;\r
-                   double pitch = 1;\r
-                       Canvas disp = new Canvas(Canvas.window, Display.secondary);\r
-                       \r
-                       var fieldW_ = Psychlops.Widgets.Browser.Element.byID("fieldW");\r
-                       var fieldH_ = Psychlops.Widgets.Browser.Element.byID("fieldH");\r
-                       var wL_     = Psychlops.Widgets.Browser.Element.byID("wL");\r
-                       var Cont_   = Psychlops.Widgets.Browser.Element.byID("Cont");\r
-                       var ix_     = Psychlops.Widgets.Browser.Element.byID("ix");\r
-                       var iy_     = Psychlops.Widgets.Browser.Element.byID("iy");\r
-                       var gap_    = Psychlops.Widgets.Browser.Element.byID("gap");\r
-                       ///- 0 SetGlobal\r
-\r
-                       ///+ 1 Initialize\r
-                       ////initialize\r
-                       p1.centering().shift(-width*0.5 + x0, -height*0.5 + y0); //Move a point to the initial position.\r
-                       ///- 1 Initialize\r
-\r
-                       ///+ 2 Drawing\r
-                        ////drawing objects\r
-                       for(int i=0; i < width; i++)\r
-                       {\r
-                               col1.set(lmean*((contrast*Math.sin((2*Math.PI*i/lambda)))+1)); //Set a color.\r
-\r
-                               ///+ 2.1 Drawing a column\r
-                               ////drawing a column\r
-                               for(int j=0;j < height; j++)\r
-                               {\r
-                                       p1.draw(col1);\r
-                                       p1.shift(0, pitch);\r
-                               }\r
-                               ///- 2.1 Drawing a column\r
-\r
-                               p1.shift(1, -height * pitch); //back to vertical intitial point after drawing one column.\r
-                       }\r
-                       disp.flip();\r
-                       ///- 2 Drawing\r
-\r
-                       while (!Keyboard.spc.pushed()) { }; //Wait until space key is pressed.\r
-               }\r
-\r
-\r
-       }\r
-\r
-}\r
- * */\r
-\r
-\r
-/*\r
-///+ Prefix\r
-//// Lines for set up Psychlops environment\r
-using Psychlops;\r
-\r
-namespace PsychlopsSilverlightApp\r
-{\r
-\r
-       public class PsychlopsMain\r
-       {///- Prefix\r
-\r
-\r
-\r
-               ///+ Main Routine\r
-               //// Psychlops runs at the first line of this function psychlops_main().\r
-               public void psychlops_main()\r
-               {\r
-                       Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.\r
-\r
-                       var FIGURE = 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
-                       var COLOR_BG = Psychlops.Widgets.Browser.Element.byID("COLOR_BG");\r
-                       var Period_Size = Psychlops.Widgets.Browser.Element.byID("Period_Size");\r
-                       var Period_Position = Psychlops.Widgets.Browser.Element.byID("Period_Position");\r
-                       var Speed_HSize_ = Psychlops.Widgets.Browser.Element.byID("Speed_HSize");\r
-                       var Speed_VSize = Psychlops.Widgets.Browser.Element.byID("Speed_VSize");\r
-                       var Speed_VMotion = Psychlops.Widgets.Browser.Element.byID("Speed_VMotion");\r
-                       double SIZE_X = SIZE_X_, SIZE_Y = SIZE_Y_;\r
-\r
-                       ///+ 2\r
-                       ////  Set a figure size, position and color.\r
-                       Rectangle figure = new Rectangle();\r
-                       Ellipse figure2 = new Ellipse();\r
-                       figure.set(SIZE_X_, SIZE_Y_); // Set the size of figure.\r
-                       figure2.set(SIZE_X_, SIZE_Y_); // Set the size of figure.\r
-                       figure.centering().shift(0, 0); // Move the figure to the starting point.\r
-                       figure2.centering().shift(0, 0); // Move the figure to the starting point.\r
-                       ///- 2\r
-\r
-                       int frame = 0;\r
-                       int looming_direction = 1, motion_dir = 1;\r
-                       double direction = 1.0;\r
-                       //looming_direction is a variable for size change.\r
-                       //motion_dir is a variable for motion direction.\r
-                       ///+ 3 Drawing loop\r
-                       //// Draw each frames in a "while loop".\r
-                       while (!Keyboard.esc.pushed())\r
-                       { //exit a program when the escape key is pressed down.\r
-                               window.clear(COLOR_BG); // Clear the window with a designated gray-scale level.\r
-\r
-                               ///+ 3.1\r
-                               //// Calculate object's position and size for each frame.\r
-\r
-                               if (frame % Period_Size == 0)\r
-                               { // a direction of size change will reverse at designated frames.\r
-                                       looming_direction = looming_direction * -1;\r
-                               }\r
-\r
-                               if (frame % Period_Position == 0)\r
-                               { // motion direction will reverse at designated frames.\r
-                                       motion_dir *= -1;\r
-                               }\r
-\r
-                               ///- 3.1\r
-\r
-                               ///+ 3.2 \r
-                               //// Settting figure's properties\r
-                               figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".\r
-                                                                figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".\r
-                               figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". \r
-                               figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".\r
-                                                               figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".\r
-                               figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". \r
-                               /*\r
-                               figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".\r
-                                                        figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".\r
-                               figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". \r
-                               figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".\r
-                                                               figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".\r
-                               figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". \r
-                                * * /\r
-                               ///- 3.2\r
-\r
-                               ///+ 3.3 \r
-                               ////Drawing\r
-                               if ("Rectangle".Equals(FIGURE))\r
-                               {\r
-                                       figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.\r
-                               }\r
-                               else\r
-                               {\r
-                                       figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.\r
-                               }\r
-                               window.flip(); // Reflect the drawing for the display by flipping frame buffers.\r
-                               ///- 3.3\r
-\r
-                               ///+ 3.4\r
-                               ////make a step for next frames \r
-                               frame++;\r
-                               ///- 3.4\r
-                       }\r
-                       ///- 3 Drawing loop\r
-\r
-               }\r
-               ///- Main Routine\r
-\r
-\r
-       }\r
-\r
-}\r
-\r
-\r
-\r
-/*\r
-//The reversed-phi motion.\r
-//Anstis (1970)\r
-//Phi movement as a subtraction process. Vision Res 10:1411?1430\r
-\r
-///+ Prefix\r
-//// Include Psychlops Package\r
-using Psychlops;\r
-\r
-namespace PsychlopsSilverlightApp\r
-{\r
-\r
-       public class PsychlopsMain\r
-       {\r
-\r
-               ///- Prefix\r
-\r
-               ///+ Stimulus drawing function\r
-               //// A function for stimulus drawing (main body)\r
-               void RectLuminance()\r
-               {\r
-\r
-                       ///+ Preperation\r
-                       //// Declare and initialize local variables\r
-                       double rect_size = 20;\r
-\r
-                       double bg_lum = 0.5;\r
-                       double radii = 200;\r
-                       double rect_lum;\r
-                       int element_number = 25;\r
-                       int radial_row = 5;\r
-\r
-                       double rotation_tf = 0.2;\r
-                       double polarity = 1;\r
-                       double rotation;\r
-\r
-                       double contrastflag = 1;\r
-                       int period = 3;\r
-                       double refresh;\r
-\r
-                       Canvas display = new Canvas(Canvas.window); //Prepare drawing window\r
-                       refresh = Display.getRefreshRate();\r
-\r
-                       Ellipse rect = new Ellipse();\r
-                       rect.set(rect_size, rect_size);\r
-\r
-                       Ellipse fixation = new Ellipse(5, 5);\r
-                       fixation.centering();\r
-\r
-                       Letters let1 = new Letters("Press Space key to change stimulus type");\r
-                       let1.centering().shift(-180, 220);\r
-                       Letters let2 = new Letters("Phi");\r
-                       let2.centering().shift(-10, 200);\r
-                       Letters let3 = new Letters("Reversed-Phi");\r
-                       let3.centering().shift(-60, 200);\r
-\r
-                       rotation = Math.random(2 * Math.PI);\r
-\r
-                       ///+ user interface\r
-                       ////register variables to demo circumstances\r
-                       Interval rng = new Interval();\r
-\r
-                       Psychlops.Widgets.Slider rect_contrast;\r
-                       rect_contrast = new Psychlops.Widgets.Slider("Contrast", 0.1 <= rng <= 1.0, 0.1);\r
-                       rect_contrast.value = 0.5;\r
-                       ///- user interface\r
-                       ///- Preperation\r
-\r
-                       ///+ Main loop\r
-                       ////Main loop\r
-                       int frame = 0;\r
-                       //AppState::setThreadPriority(AppState::HIGH);\r
-                       while (true)\r
-                       {\r
-                               frame++;\r
-                               if (Keyboard.spc.pushed()) contrastflag = -contrastflag;\r
-                               if (contrastflag < 0) polarity = -polarity;\r
-                               rotation = 2 * Math.PI * rotation_tf * frame * period / refresh;\r
-\r
-                               for (int frame_now = 0; frame_now < period; frame_now++)\r
-                               {\r
-                                       Display.clear(new Color(bg_lum));\r
-                                       for (int j = 0; j < radial_row; j++)\r
-                                       {\r
-                                               rect.resize(rect_size * (j + radial_row) / 10.0, rect_size * (j + radial_row) / 10.0);\r
-                                               for (double i = 0; i < element_number; i++)\r
-                                               {\r
-                                                       rect_lum = bg_lum * (1.0 + polarity * rect_contrast);\r
-                                                       rect.centering().shift(radii * (j + radial_row) / 10.0 * Math.cos(rotation + i * 2 * Math.PI / element_number), radii * (j + radial_row) / 10.0 * Math.sin(rotation + i * 2 * Math.PI / element_number));\r
-                                                       rect.draw(rect_lum);\r
-                                               }\r
-                                       }\r
-                                       fixation.draw(Color.red);\r
-                                       let1.draw();\r
-                                       if (contrastflag > 0) let2.draw();\r
-                                       else let3.draw();\r
-                                       Display.flip();\r
-                               }\r
-                       }\r
-                       ///- Main loop\r
-                       //AppState::setThreadPriority(AppState::NORMAL);\r
-               }\r
-               ///- Stimulus drawing function\r
-\r
-               ///+ Main function for demo circumstances\r
-               //// Psychlops Main function\r
-               public void psychlops_main()\r
-               {\r
-                       ///+ Demo circumstances\r
-                       //// Spells for run demonstration circumstances\r
-                       Procedure p = new Procedure();\r
-                       //p.setDesign(Procedure::DEMO); //Designate that this is a demo.\r
-                       p.setProcedure(RectLuminance);  //The argument name is a name of drawing function.\r
-                       p.run();\r
-                       ///- Demo circumstances\r
-               }\r
-               ///- Main function for demo circumstances\r
-\r
-       }\r
-\r
-}\r
-\r
-\r
-\r
-/*\r
-//Two types of plaid motion\r
-//E. H. Adelson and J. A. Movshon (1982).\r
-//Phenomenal coherence of moving visual patterns. Nature 300, 523-525\r
-\r
-///+ Prefix\r
-//// Include Psychlops Package\r
-using Psychlops;\r
-\r
-       namespace PsychlopsSilverlightApp\r
-       {\r
-\r
-               public class PsychlopsMain\r
-               {\r
-                       ///- Prefix\r
-\r
-                       ///+ Global\r
-                       // Struct for component paremeters\r
-                       struct component\r
-                       {\r
-                               public double contrast;\r
-                               public double orientation;\r
-                               public double lambda;\r
-                               public double tf;\r
-                       }\r
-                       ///- Global\r
-\r
-                       ///+ Stimulus drawing function\r
-                       //// A function for stimulus drawing (main body)\r
-                       void drawgratingmovie(Image[] img, component c1, component c2, double contrast, int start, int maxframe, double bg_lum, double alpha)\r
-                       {\r
-                               double _xp, _xp2, col1, col2;\r
-                               double contrast1, contrast2;\r
-                               double imageheight, imagewidth;\r
-\r
-                               contrast1 = contrast*c1.contrast/(c1.contrast+c2.contrast);\r
-                               contrast2 = contrast*c2.contrast/(c1.contrast+c2.contrast);\r
-\r
-                               imageheight = img[0].getHeight();\r
-                               imagewidth = img[0].getWidth();\r
-\r
-                               for(int frame=start; frame<start+maxframe+1; frame++){\r
-                                       //Display.progressbar(frame, maxframe+1);\r
-                                       //img[frame].convert(Image::RGBA);\r
-                                       for(int i=0; i<imagewidth; i++){\r
-                                               for(int j=0; j<imageheight; j++){\r
-                                                       _xp = Math.sin(c1.orientation)*(i-imagewidth*0.5) + Math.cos(c1.orientation) * (j-imageheight *0.5);\r
-                                                       _xp2 = Math.sin(c2.orientation)*(i-imagewidth*0.5) + Math.cos(c2.orientation) * (j-imageheight *0.5);\r
-                                                       col1 = bg_lum*contrast1*Math.sin(2*Math.PI*_xp/c1.lambda + 2*Math.PI*c1.tf*frame/(double)refresh);\r
-                                                       col2 = bg_lum*contrast2*Math.sin(2*Math.PI*_xp2/c2.lambda + 2*Math.PI*c2.tf*frame/(double)refresh);\r
-                                                       img[frame].pix(i,j,new Color(col1+col2+bg_lum));\r
-                                                       img[frame].alpha(i,j,alpha);\r
-                                               }\r
-                                       }\r
-                                       //img[frame].cache();\r
-                               }\r
-                       }\r
-\r
-                       ///+ Stimulus drawing function\r
-                       //// A function for stimulus drawing (main body)\r
-                       void drawplaid() {\r
-                               Canvas display = new Canvas(Canvas.window);\r
-                               ///+ Preperation\r
-                               //// Declare and initialize local variables\r
-                               int rect_size = 150;\r
-                               double rect_lum  = 0.5;\r
-                               double bg_lum    = 0.2;\r
-                               double duration = 400;\r
-\r
-                               double[] lambda = new double[2], contrast = new double[2], tf = new double[2];\r
-                               double center_orientation = 0.0;\r
-                               Image[,] movie = StaticFunctions.NewArray<Image>(2, 120);\r
-                               Image[,] component_movie = StaticFunctions.NewArray<Image>(4, 120);\r
-                               Image envelope = new Image(), envelope_small = new Image();\r
-\r
-                               for(int i=0; i<120; i++)\r
-                               {\r
-                                       movie[0, i].set(rect_size, rect_size);\r
-                                       movie[1, i].set(rect_size, rect_size);\r
-                                       component_movie[0, i].set(rect_size/2, rect_size/2);\r
-                                       component_movie[1, i].set(rect_size/2, rect_size/2);\r
-                                       component_movie[2, i].set(rect_size/2, rect_size/2);\r
-                                       component_movie[3, i].set(rect_size/2, rect_size/2);\r
-                               }\r
-                               envelope.set(rect_size, rect_size);\r
-                               envelope_small.set(rect_size/2, rect_size/2);\r
-\r
-                               Letters let1 = new Letters(), let2 = new Letters(), let3 = new Letters();\r
-                               let1.str = "Component1";\r
-                               let2.str = "Component2";\r
-                               let3.str = "Superposition";\r
-                               let1.centering().shift(-rect_size*1.25, -rect_size);\r
-                               //let1.cache();\r
-                               let2.centering().shift(rect_size*1.25, -rect_size);\r
-                               //let2.cache();\r
-                               let3.centering().shift(0.0, rect_size*0.75);\r
-                               //let3.cache();\r
-\r
-                               component c1, c2, c0;\r
-                               c0 = new component{ 0.0,0.0,1.0,1.0 }; //dummy for component movie\r
-                               ///+ type-I\r
-                               // Prepare Type-I plaid movie\r
-                               center_orientation = 0.0;\r
-                               orientation_offset = Math.PI/6;\r
-                               contrast[0] = 1.0, contrast[1] = 1.0;\r
-                               lambda[0] = 30.0, lambda[1] = 30.0;\r
-                               tf[0] = 1.0; tf[1] = 1.0;\r
-\r
-                               c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};\r
-                               c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};\r
-\r
-                       drawgratingmovie(movie[0],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       drawgratingmovie(component_movie[0],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       drawgratingmovie(component_movie[1],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       ///- type-I\r
-\r
-                       ///+ type-II\r
-                       // Prepare Type-II plaid movie\r
-                       center_orientation = -0.0, orientation_offset = Math.PI/12;\r
-                       contrast[0] = 1.0, contrast[1] = 1.0;\r
-                       lambda[0] = 30.0, lambda[1] = 30.0;\r
-                       tf[0] = 1.0; tf[1] = 4.0;\r
-\r
-                       c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};\r
-                       c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};\r
-\r
-                       drawgratingmovie(movie[1],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       drawgratingmovie(component_movie[2],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       drawgratingmovie(component_movie[3],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);\r
-                       ///- type-II\r
-\r
-                       ///+ gaussian\r
-                       //draw Gaussian envelopes\r
-                       envelope.clear(new Color(bg_lum)); //clear offscreen image\r
-                       double _x, _y;\r
-                       for(int i=0; i<rect_size; i++){\r
-                       _x=i-0.5*rect_size;\r
-                       for(int j=0; j<rect_size; j++){\r
-                       _y=j-0.5*rect_size;\r
-                       envelope.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/6.0, 2.0) ))));\r
-                       }\r
-                       }\r
-\r
-                       envelope_small.clear(new Color(bg_lum)); //clear offscreen image\r
-                       for(int i=0; i<rect_size*0.5; i++){\r
-                       _x=i-0.25*rect_size;\r
-                       for(int j=0; j<rect_size*0.5; j++){\r
-                       _y=j-0.25*rect_size;\r
-                       envelope_small.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/12.0, 2.0) ))));\r
-                       }\r
-                       }\r
-                       envelope.cache(); //send offscreen image from main memory to GPU\r
-                       envelope_small.cache(); //send offscreen image from main memory to GPU\r
-                       ///- gaussian\r
-\r
-                       ///+ user interface\r
-                       // Draw user interface\r
-                       Widgets::SelectBox stimulus_type;\r
-                       stimulus_type.area.set(120, 20);\r
-                       stimulus_type.append(L"TypeI");\r
-                       stimulus_type.append(L"TypeII");\r
-                       stimulus_type.centering().shift(-120.0,250.0);\r
-\r
-                       Psychlops::Widgets::SelectBox stimulus_type2;\r
-                       stimulus_type2.area.set(120, 20);\r
-                       stimulus_type2.append(L"Continuous");\r
-                       stimulus_type2.append(L"Periodic");\r
-                       stimulus_type2.centering().shift(120.0,250.0);\r
-\r
-                       Psychlops::Widgets::Slider duration_slider;\r
-                       duration_slider.area.set(100,20);\r
-                       duration_slider.centering().shift(120,280.0);\r
-                       Interval rng = new Interval();\r
-                       duration_slider.link(duration, 50<=rng<=950, 50.0, 50.0);\r
-                       ///- user interface\r
-                       ///- Preperation\r
-\r
-                       ///+ Main loop\r
-                       int frame = 0;\r
-                       int period = refresh_int;\r
-                       int movienum;\r
-                       while(!Keyboard.esc.pushed()) {\r
-                       Display.clear(new Color(bg_lum));\r
-                       movienum = stimulus_type.getSelected(); //if "Type-I" is selected, 0, else frame refresh per sec\r
-\r
-                       in;\r
-                       else period = refresh_int;\r
-\r
-                       if(frame>0){\r
-                       movie[movienum, frame].centering().draw();\r
-                       envelope.centering().draw();\r
-                       component_movie[movienum*2, frame].centering().shift(-rect_size*0.5, -rect_size).draw();\r
-                       envelope_small.centering().shift(-rect_size*0.5, -rect_size).draw();\r
-                       component_movie[movienum*2+1, frame].centering().shift(rect_size*0.5, -rect_size).draw();\r
-                       envelope_small.centering().shift(rect_size*0.5, -rect_size).draw();\r
-                       }\r
-\r
-                       ///+ draw user interface\r
-                       let1.draw(0.75);\r
-                       let2.draw(0.75);\r
-                       let3.draw(0.75);\r
-                       stimulus_type.draw();\r
-                       stimulus_type2.draw();\r
-                       if(stimulus_type2.getSelected())duration_slider.draw();\r
-                       ///- draw user interface\r
-                       Display.flip();\r
-                       if(frame++ >= period) frame -= refresh_int;\r
-                       }\r
-                       ///- Main loop\r
-\r
-                       }\r
-                       ///- Stimulus drawing function\r
-\r
-               ///+ Main function for demo circumstances\r
-               public void psychlops_main() {\r
-                       ///+ Demo circumstances\r
-                       //// Spells for run demonstration circumstances\r
-                       Procedure p = new Procedure();\r
-                       //p.setDesign(Procedure::DEMO); //Designate that this is a demo.\r
-                       p.setProcedure(drawplaid);  //The argument name is a name of drawing function.\r
-                       p.run();\r
-                       ///- Demo circumstances\r
-               }\r
-       }\r
-}\r
-*/\r