\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
+///+ 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
*/\r
\r
\r
-\r
+/*\r
using Psychlops;\r
//Position Bias Program\r
namespace PsychlopsSilverlightApp\r
}\r
}\r
}\r
+*/
\ No newline at end of file