- window.clear(Color.black);\r
- for (int i = 0; i < rectnum; i++)\r
- {\r
- ///+ 2.2 loopset1\r
- ////set positions and sizes\r
-\r
- Horizontal_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 100.0; //Calculate horizontal displacement from the center.\r
- Vertical_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 0.0;//Calculate vertical displacement from the center.\r
- rect[i].resize(rectsize, rectsize); //Resize rectangles.\r
- rect[i].centering(); //Rectangles are moved to the center...\r
- rect[i].shift(Horizontal_shift + (i - 0.5 * rectnum) * rectsize * 1.5,\r
- Vertical_shift + (i - 0.5 * rectnum) * rectsize * 1.5); //and then move to designated positions\r
- ///- 2.2 loopset1\r
-\r
- ///+ 2.3 linkto BasicCode3_2a\r
- ////set colors \r
- rectcolorR[i] = Math.random(1.0) * 0.5; //Set R values. Note that "i" is converted to double-type.\r
- rectcolorG[i] = Math.random(1.0) * 0.5; //Set G values. Note that "i" is converted to double-type.\r
- rectcolorB[i] = Math.random(1.0) * 0.5; //Set B values. Note that "i" is converted to double-type.\r
- ///- 2.3 linkto BasicCode3_2a\r
-\r
- }\r
- ///+ 2.4 linkto BasicCode3_1a\r
- for (int i = 0; i < rectnum; i++)\r
- {\r
- rect[i].draw(new Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors.\r
- }\r
- window.flip();\r
- ///- 2.4 linkto BasicCode3_1a\r
- frame++;\r
- }\r
- ///- 2 drawing\r
-\r
- }\r
- ///- Main Routine\r
-\r
-\r
- }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-using Psychlops;\r
-\r
-namespace PsychlopsSilverlight4test\r
-{\r
-\r
- public class PsychlopsMain\r
- {\r
- void RectLuminance()\r
- {\r
- Canvas display = new Canvas(Canvas.window);\r
- Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
- Letters le = new Letters("Reload to restart");\r
- le.fill = Color.black;\r
- le.align = Letters.HorizontalAlign.center;\r
-\r
- while (!Keyboard.esc.pushed())\r
- {\r
- Display.clear(Color.white);\r
- le.centering().shift(-200,-10).draw();\r
- Display.flip();\r
- }\r
-\r
- }\r
-\r
-\r
- public void psychlops_main()\r
- {\r
- RectLuminance();\r
- }\r
-\r
-\r
- }\r
-\r
-}\r
-\r
-*/\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-/*\r
- using Psychlops;\r
-\r
-namespace PsychlopsSilverlight4test\r
-{\r
-\r
- public class PsychlopsMain\r
- {\r
-\r
- Psychlops.Canvas cnvs;\r
- int i;\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 Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
- Psychlops.Widgets.Slider thetaSpeed, DotNumber;\r
- Image img;\r
-\r
-\r
-\r
- public void psychlops_main()\r
- {\r
- cnvs = new Canvas(500, 500);\r
-\r
- Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
-\r
-\r
- img = new Image("Resources/logo.png");\r
-\r
- Interval rng = new Interval();\r
- thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);\r
- DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);\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
- //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
- //DotNumber = 200;\r
- //Main stimulus loop\r
- while(true){\r
- //Clear the main window\r
- cnvs.clear();\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
- for (int i = 0; i < 5; i++)\r