X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=859b016004144470336c39fcbc55b8a805096833;hb=0aaced545d70ae3bd6cdd440e0ce676f6a602761;hp=3fd2ba9f6621b4235e6d9591fc2de06fef58f33f;hpb=e7ec2e7cdb0c8c7e9c0db62998be4b2803180fdc;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 3fd2ba9..859b016 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,293 +1,72 @@  -/* +///+ Prefix linkto BasicCode1 +//// Lines for set up Psychlops environment using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { - public class PsychlopsMain - { + {///- Prefix linkto BasicCode1 - Canvas cnvs; - int i; - object xxx; - 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 DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0; - Psychlops.Widgets.Slider DotNumberS; + ///+ Main Routine + //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500)); - //Independent ind = new Independent(); - - cnvs = new Canvas(500, 500); - - Image img = new Image(100, 100); - img.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); }); - Image img2 = new Image(100, 100); - img2.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); }); - /* - for (int x = 0; x < 20; x++) + ///+ 0 Declaration + ////Prepare global parameters + Canvas window = new Canvas(Canvas.window); + Image img; + Rectangle centerrect = new Rectangle(10, 10); + int imageHsize = 100; + int imageVsize = 60; + double R, G, B; + ///- 0 Declaration + + + + ///+ 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++) { - for (int y = 0; y < 20; y++) + for (int j = 0; j < imageVsize; j++) { -// img.pix(x, y, new Color(Math.sin(x + y))); + ///+ 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(); } } + //img.cache(); //Move offscreen from main memory to video RAM. (Optional) + ///- 1 Initialize - //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]; - - - //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 = 100; - //Main stimulus loop - while(true){ - //Clear the main window - cnvs.clear(Color.green); - - - 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