\r
-///+ Prefix linkto BasicCode1\r
+///+ Prefix\r
//// Lines for set up Psychlops environment\r
using Psychlops;\r
\r
{\r
\r
public class PsychlopsMain\r
- {///- Prefix linkto BasicCode1\r
-\r
+ {///- Prefix\r
\r
///+ Main Routine\r
//// Psychlops runs at the first line of this function psychlops_main().\r
public void psychlops_main()\r
{\r
- ///+ 0 Declaration\r
- ////Prepare global parameters\r
- Canvas window = new Canvas(Canvas.window);\r
- Image img;\r
- Rectangle centerrect = new Rectangle(10, 10);\r
- int imageHsize = 100;\r
- int imageVsize = 60;\r
- double R, G, B;\r
- ///- 0 Declaration\r
-\r
-\r
-\r
- ///+ 1 Initialize\r
- ////Initialize image and set color to each pixel.\r
- img = new Image(imageHsize, imageVsize); //Allocate offscreen in main memory.\r
- Color col = new Color(0,0,0);\r
- for (int i = 0; i < imageHsize; i++)\r
- {\r
- for (int j = 0; j < imageVsize; j++)\r
- {\r
- ///+ 1.1 set1\r
- ////set colors for each pixels\r
- R = Math.random(1.0) * 0.5; //Set R values. \r
- G = Math.random(1.0) * 0.5; //Set G values.\r
- B = Math.random(1.0) * 0.5; //Set B values. \r
- col.set(R, G, B);\r
- img.pix(i, j, col);\r
- ///- 1.1 set1\r
- centerrect.centering();\r
- }\r
- }\r
+ ///+ 1\r
+ //// Set a window for drawing stimulus\r
+ Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.\r
+ // You can write this statement as" Canvas window = new Canvas(Canvas.fullscreen); " for fullscreen mode\r
+ // or as " Canvas window = new Canvas(1024, 768, 32, 60.0); " This statement changes screenmode to 1024 x 768, 32bit color, 60 Hz refresh.\r
+ ///- 1\r
\r
- //img.cache(); //Move offscreen from main memory to video RAM. (Optional)\r
- ///- 1 Initialize\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 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
- ///+ 2 drawing\r
- ////drawing offscreen\r
\r
+ ///+ 2\r
+ //// Set a figure size, position and color.\r
+ Rectangle figure = new Rectangle();\r
+ Ellipse figure2 = new Ellipse();\r
+\r
+ window.flip(); // Reflect the drawing for the display by flipping frame buffers.\r
+ // Till this point, you will not see drawn figures.\r
+ ///- 2\r
+\r
+ ///+ 3 \r
+ //// Detect a Keyboard input\r
while (!Keyboard.esc.pushed())\r
{\r
\r
- window.clear(Color.black); //Clear screen with black\r
- img.centering(); //centering the position to copy offscreen\r
- img.shift(100, 100); //centering the position to copy offscreen\r
- img.draw(); // copy offscreen onto the reverse side of window buffer.\r
- centerrect.draw(Color.red);// draw reference rectangle at the center.\r
+ window.clear();\r
+\r
+ if ("Rectangle".Equals(FIGURE))\r
+ {\r
+ figure.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
+ figure.centering(); // Centering the figure in the window\r
+ figure.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. \r
+ figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
+ }\r
+ else\r
+ {\r
+ figure2.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
+ figure2.centering(); // Centering the figure in the window\r
+ figure2.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. \r
+ figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
+ }\r
+\r
window.flip();\r
- }\r
- ///- 2 drawing\r
+\r
+ } //exit a program when the escape key is pressed down.\r
+ ///- 3\r
\r
}\r
///- Main Routine\r
}\r
\r
}\r
+\r
+\r