X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=859b016004144470336c39fcbc55b8a805096833;hb=0aaced545d70ae3bd6cdd440e0ce676f6a602761;hp=aafe41225b89fd66f465dc74f82bfbe5f3fa9246;hpb=39cda95632f7017ff1941c8162e0dbe026f56baa;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index aafe412..859b016 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,110 +1,6 @@ -///+ Prefix linkto BasicCode1 + +///+ Prefix linkto BasicCode1 //// Lines for set up Psychlops environment -<<<<<<< HEAD -using Psychlops; - -namespace PsychlopsSilverlight4test -{ - - public class PsychlopsMain - {///- Prefix linkto BasicCode1 - - - ///+ Main Routine - //// Psychlops runs at the first line of this function psychlops_main(). - public void psychlops_main() { - ///+ 0 linkto BasicCode3_1a - ////Prepare global parameters - const int maxrectnum = 200; - int rectnum = 100/*ID:rectnumber 25.0 200.0 25.0*/; - double rectsize = 5.0/*ID:dotsize 1.0 10.0 1.0*/; - Rectangle[] rect = new Rectangle[maxrectnum]; - for (int i = 0; i < maxrectnum; i++) { rect[i] = new Rectangle(); } - double[] rectcolorR = new double[maxrectnum]; - double[] rectcolorG = new double[maxrectnum]; - double[] rectcolorB = new double[maxrectnum]; - ///- 0 linkto BasicCode3_1a - - Canvas window = new Canvas(Canvas.window); - - ///+ 1 linkto BasicCode3_1a - ////Initialize - for(int i=0; i < rectnum; i++){ - ///+ 1.1 set1 - ////set positions and sizes - rect[i].set(rectsize, rectsize); //Set a size of rectangles. - rect[i].centering(); - rect[i].shift((i - 0.5 * rectnum) * rectsize* 1.5/*ID:RectHGap 1.0 3.0 0.5*/, - (i - 0.5*rectnum) * rectsize * 1.5/*ID:RectVGap 1.0 3.0 0.5*/); //Move Rectangles to initial positions - ///- 1.1 set1 - ///+ 1.2 set2 - ////set colors - rectcolorR[i]=Math.random(1.0) * 0.5/*ID: RGain 0.0 1.0 0.5*/; //Set R values. Note that "i" is converted to double-type. - rectcolorG[i]=Math.random(1.0) * 0.5/*ID: GGain 0.0 1.0 0.5*/; //Set G values. Note that "i" is converted to double-type. - rectcolorB[i]=Math.random(1.0) * 0.5/*ID: BGain 0.0 1.0 0.5*/; //Set B values. Note that "i" is converted to double-type. - ///- 1.2 set2 - } - ///- 1 linkto BasicCode3_1a - - ///+ 2 drawing - ////drawing objects - ///+ 2.1 setlocal - ////Prepare variables for movie control; - int frame = 0; - int motion_dir = 1; - double Horizontal_shift, Vertical_shift; - ///- 2.1 setlocal - - while(!Keyboard.esc.pushed()){ - window.clear(Color.black); - - if(frame % 30/*ID:Period_Position 30 240 30*/ ==0){ // motion direction will reverse at designated frames. - motion_dir *= -1; - } - - for(int i=0; i < rectnum; i++){ - ///+ 2.2 loopset1 - ////set positions and sizes - - Horizontal_shift=motion_dir * 1.0/*ID:HSpeed 0.0 5.0 1.0*/; - Vertical_shift=motion_dir * 0.0/*ID:VSpeed 0.0 5.0 1.0*/; - - rect[i].resize(rectsize, rectsize); //Resize rectangles. - rect[i].shift(Horizontal_shift, Vertical_shift); - ///- 2.2 loopset1 - - ///+ 2.3 loopset2 - ////set colors - rectcolorR[i]=Math.random(1.0)* 0.5/*ID:RGain 0.0 1.0 0.5*/; //Set R values. Note that "i" is converted to double-type. - rectcolorG[i]=Math.random(1.0)* 0.5/*ID:GGain 0.0 1.0 0.5*/; //Set G values. Note that "i" is converted to double-type. - rectcolorB[i]=Math.random(1.0)* 0.5/*ID:BGain 0.0 1.0 0.5*/; //Set B values. Note that "i" is converted to double-type. - ///- 2.3 loopset2 - - } - - ///+ 2.4 linkto BasicCode3_1a - for(int i=0; i < rectnum; i++){ - rect[i].draw(new Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors. - } - window.flip(); - ///- 2.4 linkto BasicCode3_1a - - frame++; - } - ///- 2 drawing - -} - ///- Main Routine - - - } - -} - - -/* -======= ->>>>>>> 06a470a0e79a283223a73d8c5f6e43ef76174d97 using Psychlops; namespace PsychlopsSilverlightApp @@ -118,485 +14,59 @@ namespace PsychlopsSilverlightApp //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - ///+ 0 linkto BasicCode3_1a + ///+ 0 Declaration ////Prepare global parameters - int maxrectnum = 200; - int rectnum = 100; - double rectsize = 5.0; - Rectangle[] rect = StaticFunctions.NewArray(maxrectnum); - double[] rectcolorR = new double[maxrectnum]; - double[] rectcolorG = new double[maxrectnum]; - double[] rectcolorB = new double[maxrectnum]; - ///- 0 linkto BasicCode3_1a - Canvas window = new Canvas(Canvas.window); - var img = new Image("logo.png"); + Image img; + Rectangle centerrect = new Rectangle(10, 10); + int imageHsize = 100; + int imageVsize = 60; + double R, G, B; + ///- 0 Declaration - ///+ 1 linkto BasicCode3_1a - ////Initialize - for (int i = 0; i < rectnum; i++) - { - ///+ 1.1 set1 - ////set positions and sizes - rect[i].set(rectsize, rectsize); //Set a size of rectangles. - rect[i].centering(); - rect[i].shift((i - 0.5 * rectnum) * rectsize * 1.5, - (i - 0.5 * rectnum) * rectsize * 1.5); //Move Rectangles to initial positions - ///- 1.1 set1 - ///+ 1.2 set2 - ////set colors - rectcolorR[i] = Math.random(1.0) * 0.5; //Set R values. Note that "i" is converted to double-type. - rectcolorG[i] = Math.random(1.0) * 0.5; //Set G values. Note that "i" is converted to double-type. - rectcolorB[i] = Math.random(1.0) * 0.5; //Set B values. Note that "i" is converted to double-type. - ///- 1.2 set2 - } - ///- 1 linkto BasicCode3_1a - - ///+ 2 drawing - ////drawing objects - ///+ 2.1 linkto BasicCode3_2a - ////Prepare variables for movie control; - int frame = 0; - int motion_dir = 1; - double Horizontal_shift, Vertical_shift; - ///- 2.1 linkto BasicCode3_2a - while (!Keyboard.esc.pushed()) + ///+ 1 Initialize + ////Initialize image and set color to each pixel. + img = new Image(imageHsize, imageVsize); //Allocate offscreen in main memory. + Color col = new Color(0,0,0); + for (int i = 0; i < imageHsize; i++) { - window.clear(Color.black); - for (int i = 0; i < rectnum; i++) + for (int j = 0; j < imageVsize; j++) { - ///+ 2.2 loopset1 - ////set positions and sizes - - Horizontal_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 100.0; //Calculate horizontal displacement from the center. - Vertical_shift = Math.sin(2 * Math.PI * ((double)frame / 30.0)) * motion_dir * 0.0;//Calculate vertical displacement from the center. - rect[i].resize(rectsize, rectsize); //Resize rectangles. - rect[i].centering(); //Rectangles are moved to the center... - rect[i].shift(Horizontal_shift + (i - 0.5 * rectnum) * rectsize * 1.5, - Vertical_shift + (i - 0.5 * rectnum) * rectsize * 1.5); //and then move to designated positions - ///- 2.2 loopset1 - - ///+ 2.3 linkto BasicCode3_2a - ////set colors - rectcolorR[i] = Math.random(1.0) * 0.5; //Set R values. Note that "i" is converted to double-type. - rectcolorG[i] = Math.random(1.0) * 0.5; //Set G values. Note that "i" is converted to double-type. - rectcolorB[i] = Math.random(1.0) * 0.5; //Set B values. Note that "i" is converted to double-type. - ///- 2.3 linkto BasicCode3_2a - + ///+ 1.1 set1 + ////set colors for each pixels + R = Math.random(1.0) * 0.5; //Set R values. + G = Math.random(1.0) * 0.5; //Set G values. + B = Math.random(1.0) * 0.5; //Set B values. + col.set(R, G, B); + img.pix(i, j, col); + ///- 1.1 set1 + centerrect.centering(); } - ///+ 2.4 linkto BasicCode3_1a - for (int i = 0; i < rectnum; i++) - { - rect[i].draw(new Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors. - } - window.flip(); - ///- 2.4 linkto BasicCode3_1a - frame++; } - ///- 2 drawing - - } - ///- Main Routine - - - } - -} - - - - - -/* -using Psychlops; - -namespace PsychlopsSilverlight4test -{ - - public class PsychlopsMain - { - void RectLuminance() - { - Canvas display = new Canvas(Canvas.window); - Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution); - Letters le = new Letters("Reload to restart"); - le.fill = Color.black; - le.align = Letters.HorizontalAlign.center; - - while (!Keyboard.esc.pushed()) - { - Display.clear(Color.white); - le.centering().shift(-200,-10).draw(); - Display.flip(); - } - - } - - - public void psychlops_main() - { - RectLuminance(); - } - - - } - -} -*/ - -*/ - - - - - - - - - -/* - using Psychlops; - -namespace PsychlopsSilverlight4test -{ - - public class PsychlopsMain - { - - Psychlops.Canvas cnvs; - int i; - double x, y, z, t, p, temp, xx, yy; - - //Set Target Initial Value - double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0; - - //Set Background Initial Value - double Axis = 0.0, BGRadii = 150, BGSize = 5.0; - Psychlops.Widgets.Slider thetaSpeed, DotNumber; - Image img; - - - - public void psychlops_main() - { - cnvs = new Canvas(500, 500); - - Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution); - - - img = new Image("Resources/logo.png"); - - Interval rng = new Interval(); - thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0); - DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0); - - //Declare background dots and target - Rectangle[] BGDot = new Rectangle[2048]; - for(int i=0; i<2048; i++){ - BGDot[i]=new Rectangle(); - } - Rectangle[] Target= new Rectangle[10]; - for(int i=0; i<10; i++){ - Target[i]=new Rectangle(); - } - - - //Declare Matrix to keep back ground dots' coordinate value - double[] DotX=new double[2048]; - double[] DotY = new double[2048]; + //img.cache(); //Move offscreen from main memory to video RAM. (Optional) + ///- 1 Initialize - //Set Independent variables to manipulate - - - //Initialize positions of background dots - for(int i=0; i<2048; i++){ - t=2.0*Math.PI*Math.random(1.0); - p=2.0*Math.PI*Math.random(1.0); - DotX[i]=t; - DotY[i]=p; - - x=BGRadii*Math.cos(t)*Math.cos(p); - y=BGRadii*Math.sin(t)*Math.cos(p); - BGDot[i].set(BGSize, BGSize); - BGDot[i].centering().shift(x,y); - } - - //Initialize positions of targets - for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize); - - double COS, SIN; - //DotNumber = 200; - //Main stimulus loop - while(true){ - //Clear the main window - cnvs.clear(); - - - temp=Axis/360*2*Math.PI; - COS=Math.cos(temp); - SIN=Math.sin(temp); - - //Calculate positions of background dots and set them - for(int i=0; i