X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=5fe3ea756556731c729a3b1831f8646bfa6b523d;hb=30ffbb3015380f28275c1160f625d9764e9bd2c4;hp=bc1169f19d717f28e50dc95d93a137d2277cf438;hpb=246587bb4cb0291fa3ee3ec8ed377d4234a6d1af;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index bc1169f..5fe3ea7 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,97 +1,70 @@ -///+ Prefix linkto BasicCode1 + +///+ Prefix linkto BasicCode1 //// Lines for set up Psychlops environment using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { public class PsychlopsMain - {///- Prefix linkto BasicCode1 + { + ///- Prefix linkto BasicCode1 ///+ Main Routine //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - ///+ 0 linkto BasicCode3_1a + + ///+ 0 SetGlobal ////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); - - ///+ 1 linkto BasicCode3_1a - ////Initialize - for (int i = 0; i < rectnum; i++) + Rectangle p1 = new Rectangle(1,1); + Color col1 = new Color(); + double width=50; + double height=10; + double lambda=60; + double lmean=0.25, contrast = 0.5; + double x0 = 0; + double y0 = 0; + double pitch = 1; + Canvas disp = new Canvas(Canvas.window, Display.secondary); + + var fieldW_ = Psychlops.Widgets.Browser.Element.byID("fieldW"); + var fieldH_ = Psychlops.Widgets.Browser.Element.byID("fieldH"); + var wL_ = Psychlops.Widgets.Browser.Element.byID("wL"); + var Cont_ = Psychlops.Widgets.Browser.Element.byID("Cont"); + var ix_ = Psychlops.Widgets.Browser.Element.byID("ix"); + var iy_ = Psychlops.Widgets.Browser.Element.byID("iy"); + var gap_ = Psychlops.Widgets.Browser.Element.byID("gap"); + ///- 0 SetGlobal + + ///+ 1 Initialize + ////initialize + p1.centering().shift(-width*0.5 + x0, -height*0.5 + y0); //Move a point to the initial position. + ///- 1 Initialize + + ///+ 2 Drawing + ////drawing objects + for(int i=0; i < width; 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 + col1.set(lmean*((contrast*Math.sin((2*Math.PI*i/lambda)))+1)); //Set a color. - while (!Keyboard.esc.pushed()) - { - window.clear(Color.black); - for (int i = 0; i < rectnum; i++) + ///+ 2.1 Drawing a column + ////drawing a column + for(int j=0;j < height; 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 - + p1.draw(col1); + p1.shift(0, pitch); } - ///+ 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.1 Drawing a column + + p1.shift(1, -height * pitch); //back to vertical intitial point after drawing one column. } - ///- 2 drawing + disp.flip(); + ///- 2 Drawing + while (!Keyboard.spc.pushed()) { }; //Wait until space key is pressed. } - ///- Main Routine } @@ -99,396 +72,539 @@ namespace PsychlopsSilverlight4test } - - - /* +///+ Prefix +//// Lines for set up Psychlops environment using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { 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(); - } + {///- Prefix - } + ///+ Main Routine + //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - RectLuminance(); - } + Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode. + + var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE"); + var SIZE_X_ = Psychlops.Widgets.Browser.Element.byID("SIZE_X"); + var SIZE_Y_ = Psychlops.Widgets.Browser.Element.byID("SIZE_Y"); + var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R"); + var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G"); + var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B"); + var COLOR_BG = Psychlops.Widgets.Browser.Element.byID("COLOR_BG"); + var Period_Size = Psychlops.Widgets.Browser.Element.byID("Period_Size"); + var Period_Position = Psychlops.Widgets.Browser.Element.byID("Period_Position"); + var Speed_HSize_ = Psychlops.Widgets.Browser.Element.byID("Speed_HSize"); + var Speed_VSize = Psychlops.Widgets.Browser.Element.byID("Speed_VSize"); + var Speed_VMotion = Psychlops.Widgets.Browser.Element.byID("Speed_VMotion"); + double SIZE_X = SIZE_X_, SIZE_Y = SIZE_Y_; + + ///+ 2 + //// Set a figure size, position and color. + Rectangle figure = new Rectangle(); + Ellipse figure2 = new Ellipse(); + figure.set(SIZE_X_, SIZE_Y_); // Set the size of figure. + figure2.set(SIZE_X_, SIZE_Y_); // Set the size of figure. + figure.centering().shift(0, 0); // Move the figure to the starting point. + figure2.centering().shift(0, 0); // Move the figure to the starting point. + ///- 2 + int frame = 0; + int looming_direction = 1, motion_dir = 1; + double direction = 1.0; + //looming_direction is a variable for size change. + //motion_dir is a variable for motion direction. + ///+ 3 Drawing loop + //// Draw each frames in a "while loop". + while (!Keyboard.esc.pushed()) + { //exit a program when the escape key is pressed down. + window.clear(COLOR_BG); // Clear the window with a designated gray-scale level. - } + ///+ 3.1 + //// Calculate object's position and size for each frame. -} + if (frame % Period_Size == 0) + { // a direction of size change will reverse at designated frames. + looming_direction = looming_direction * -1; + } -*/ + if (frame % Period_Position == 0) + { // motion direction will reverse at designated frames. + motion_dir *= -1; + } + ///- 3.1 + + ///+ 3.2 + //// Settting figure's properties + figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction". + figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction". + figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". + figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction". + figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction". + figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". + /* + figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction". + figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction". + figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". + figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction". + figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction". + figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir". + * * / + ///- 3.2 + + ///+ 3.3 + ////Drawing + if ("Rectangle".Equals(FIGURE)) + { + figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position. + } + else + { + figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position. + } + window.flip(); // Reflect the drawing for the display by flipping frame buffers. + ///- 3.3 + ///+ 3.4 + ////make a step for next frames + frame++; + ///- 3.4 + } + ///- 3 Drawing loop + } + ///- Main Routine + } +} /* - using Psychlops; +//The reversed-phi motion. +//Anstis (1970) +//Phi movement as a subtraction process. Vision Res 10:1411?1430 -namespace PsychlopsSilverlight4test +///+ Prefix +//// Include Psychlops Package +using Psychlops; + +namespace PsychlopsSilverlightApp { 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; - - + ///- Prefix - public void psychlops_main() + ///+ Stimulus drawing function + //// A function for stimulus drawing (main body) + void RectLuminance() { - cnvs = new Canvas(500, 500); - Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution); + ///+ Preperation + //// Declare and initialize local variables + double rect_size = 20; + double bg_lum = 0.5; + double radii = 200; + double rect_lum; + int element_number = 25; + int radial_row = 5; - 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); + double rotation_tf = 0.2; + double polarity = 1; + double rotation; - //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(); - } + double contrastflag = 1; + int period = 3; + double refresh; + Canvas display = new Canvas(Canvas.window); //Prepare drawing window + refresh = Display.getRefreshRate(); - //Declare Matrix to keep back ground dots' coordinate value - double[] DotX=new double[2048]; - double[] DotY = new double[2048]; + Ellipse rect = new Ellipse(); + rect.set(rect_size, rect_size); + Ellipse fixation = new Ellipse(5, 5); + fixation.centering(); - //Set Independent variables to manipulate + Letters let1 = new Letters("Press Space key to change stimulus type"); + let1.centering().shift(-180, 220); + Letters let2 = new Letters("Phi"); + let2.centering().shift(-10, 200); + Letters let3 = new Letters("Reversed-Phi"); + let3.centering().shift(-60, 200); + rotation = Math.random(2 * Math.PI); - //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; + ///+ user interface + ////register variables to demo circumstances + Interval rng = new Interval(); - 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); - } + Psychlops.Widgets.Slider rect_contrast; + rect_contrast = new Psychlops.Widgets.Slider("Contrast", 0.1 <= rng <= 1.0, 0.1); + rect_contrast.value = 0.5; + ///- user interface + ///- Preperation - //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 0) let2.draw(); + else let3.draw(); + Display.flip(); } - - img.centering(Mouse.position).draw(); - - cnvs.var(Mouse.position.x, 100, 100); - cnvs.var(Mouse.position.y, 100, 140); - - //Reflect drawing at the next frame; - cnvs.flip(); } + ///- Main loop + //AppState::setThreadPriority(AppState::NORMAL); } - } + ///- Stimulus drawing function -} -*/ - - -/*using Psychlops; - -namespace PsychlopsSilverlight4test -{ - public class PsychlopsMain - { + ///+ Main function for demo circumstances + //// Psychlops Main function public void psychlops_main() { - var figure_type = Psychlops.Widgets.Browser.Element.byID("FIGURE"); - var size_x = Psychlops.Widgets.Browser.Element.byID("SIZE_X"); - var size_y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y"); - var shift_x = Psychlops.Widgets.Browser.Element.byID("SHIFT_X"); - var shift_y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y"); - var color_r = Psychlops.Widgets.Browser.Element.byID("COLOR_R"); - var color_g = Psychlops.Widgets.Browser.Element.byID("COLOR_G"); - var color_b = Psychlops.Widgets.Browser.Element.byID("COLOR_B"); - - Canvas window = new Canvas(300, 300); - - var figure_r = new Rectangle(); - var figure_e = new Ellipse(); - Shape figure = figure_r; - - while (!Keyboard.esc.pushed()) - { - if (System.String.Compare(figure_type, "Rectangle") == 0) - { - figure_r.set(size_x, size_y); - figure = figure_r; - } - else - { - figure_e.set(size_x, size_y); - figure = figure_e; - } - figure.fill = new Color(color_r, color_g, color_b); - - window.clear(Color.black); - figure.centering().shift(shift_x, shift_y).draw(); - window.flip(); - } + ///+ Demo circumstances + //// Spells for run demonstration circumstances + Procedure p = new Procedure(); + //p.setDesign(Procedure::DEMO); //Designate that this is a demo. + p.setProcedure(RectLuminance); //The argument name is a name of drawing function. + p.run(); + ///- Demo circumstances } + ///- Main function for demo circumstances + } } - /* -using Psychlops; - -namespace Psychlops -{ - - public class RandomDots - { - Rectangle dot; - public Point[] cood; - public RandomDots() - { - cood = new Point[250]; - dot = new Rectangle(5, 5); - } - public void draw() - { - dot.fill = Color.white; - foreach (Point p in cood) - { - dot.centering(p).draw(); - } - } - } - -} - +//Two types of plaid motion +//E. H. Adelson and J. A. Movshon (1982). +//Phenomenal coherence of moving visual patterns. Nature 300, 523-525 +///+ Prefix +//// Include Psychlops Package +using Psychlops; -namespace PsychlopsSilverlight4test -{ - - public class PsychlopsMain + namespace PsychlopsSilverlightApp { - Canvas cnvs; - Image img; - Ellipse fixation; - Shape shape; - Color col; - int isize = 100; - double tfreq = 1; - int frames; - RandomDots dots; - Group g; - public void psychlops_main() + public class PsychlopsMain { - cnvs = new Canvas(500, 500); - g = new Group(); - img = new Image(isize * 2, isize * 2); - Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60); - g.append(img); - g.rotation = 50; - fixation = new Ellipse(10, 10); - fixation.fill = Color.red; - //var poly = new Rectangle(100, 100); - var poly = new Letters("日本語"); - //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0); - //var poly = new Ellipse(100, 100); - //var poly = new Line(0,0,100, 0); - poly.fill = Color.red; - poly.stroke = new Stroke { color = Color.yellow, thick = 1 }; - shape = poly; - - var rng = new Interval(); - var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100); - - dots = new RandomDots(); + ///- Prefix - - while (true) + ///+ Global + // Struct for component paremeters + struct component { - frames++; - + public double contrast; + public double orientation; + public double lambda; + public double tf; + } + ///- Global - cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5)); - col.set(Math.random(1.0)); + ///+ Stimulus drawing function + //// A function for stimulus drawing (main body) + void drawgratingmovie(Image[] img, component c1, component c2, double contrast, int start, int maxframe, double bg_lum, double alpha) + { + double _xp, _xp2, col1, col2; + double contrast1, contrast2; + double imageheight, imagewidth; + + contrast1 = contrast*c1.contrast/(c1.contrast+c2.contrast); + contrast2 = contrast*c2.contrast/(c1.contrast+c2.contrast); + + imageheight = img[0].getHeight(); + imagewidth = img[0].getWidth(); + + for(int frame=start; frame(2, 120); + Image[,] component_movie = StaticFunctions.NewArray(4, 120); + Image envelope = new Image(), envelope_small = new Image(); + + for(int i=0; i<120; i++) { - fixation.centering().shift(100, 100); - fixation.draw(new Stroke(Color.blue, 3)); - }* / - - fixation.centering().shift(slider, 0); - fixation.draw(Color.red); - - //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60); - //Figures.drawGaussian(ref img, 20, 1); - //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60); - //img.centering(Mouse.position); - //img.draw(); - g.centering(Mouse.position).draw(); - g.rotation += 1; - - shape.centering(Mouse.position).shift(100, 0); - shape.draw(); - if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100); + movie[0, i].set(rect_size, rect_size); + movie[1, i].set(rect_size, rect_size); + component_movie[0, i].set(rect_size/2, rect_size/2); + component_movie[1, i].set(rect_size/2, rect_size/2); + component_movie[2, i].set(rect_size/2, rect_size/2); + component_movie[3, i].set(rect_size/2, rect_size/2); + } + envelope.set(rect_size, rect_size); + envelope_small.set(rect_size/2, rect_size/2); + + Letters let1 = new Letters(), let2 = new Letters(), let3 = new Letters(); + let1.str = "Component1"; + let2.str = "Component2"; + let3.str = "Superposition"; + let1.centering().shift(-rect_size*1.25, -rect_size); + //let1.cache(); + let2.centering().shift(rect_size*1.25, -rect_size); + //let2.cache(); + let3.centering().shift(0.0, rect_size*0.75); + //let3.cache(); + + component c1, c2, c0; + c0 = new component{ 0.0,0.0,1.0,1.0 }; //dummy for component movie + ///+ type-I + // Prepare Type-I plaid movie + center_orientation = 0.0; + orientation_offset = Math.PI/6; + contrast[0] = 1.0, contrast[1] = 1.0; + lambda[0] = 30.0, lambda[1] = 30.0; + tf[0] = 1.0; tf[1] = 1.0; + + c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]}; + c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]}; + + drawgratingmovie(movie[0],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0); + drawgratingmovie(component_movie[0],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0); + drawgratingmovie(component_movie[1],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0); + ///- type-I + + ///+ type-II + // Prepare Type-II plaid movie + center_orientation = -0.0, orientation_offset = Math.PI/12; + contrast[0] = 1.0, contrast[1] = 1.0; + lambda[0] = 30.0, lambda[1] = 30.0; + tf[0] = 1.0; tf[1] = 4.0; + + c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]}; + c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]}; + + drawgratingmovie(movie[1],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0); + drawgratingmovie(component_movie[2],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0); + drawgratingmovie(component_movie[3],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0); + ///- type-II + + ///+ gaussian + //draw Gaussian envelopes + envelope.clear(new Color(bg_lum)); //clear offscreen image + double _x, _y; + for(int i=0; i0){ + movie[movienum, frame].centering().draw(); + envelope.centering().draw(); + component_movie[movienum*2, frame].centering().shift(-rect_size*0.5, -rect_size).draw(); + envelope_small.centering().shift(-rect_size*0.5, -rect_size).draw(); + component_movie[movienum*2+1, frame].centering().shift(rect_size*0.5, -rect_size).draw(); + envelope_small.centering().shift(rect_size*0.5, -rect_size).draw(); + } - for (int i = 0; i < dots.cood.Length; i++) - { - dots.cood[i].set(Math.random(500), Math.random(500)); - } - cnvs.var((double)slider, 200, 200); - dots.draw(); + ///+ draw user interface + let1.draw(0.75); + let2.draw(0.75); + let3.draw(0.75); + stimulus_type.draw(); + stimulus_type2.draw(); + if(stimulus_type2.getSelected())duration_slider.draw(); + ///- draw user interface + Display.flip(); + if(frame++ >= period) frame -= refresh_int; + } + ///- Main loop - cnvs.flip(); } + ///- Stimulus drawing function + + ///+ Main function for demo circumstances + public void psychlops_main() { + ///+ Demo circumstances + //// Spells for run demonstration circumstances + Procedure p = new Procedure(); + //p.setDesign(Procedure::DEMO); //Designate that this is a demo. + p.setProcedure(drawplaid); //The argument name is a name of drawing function. + p.run(); + ///- Demo circumstances } } } - -**/ +*/ /* - using Psychlops; -namespace PsychlopsSilverlight4test +//Position Bias Program +namespace PsychlopsSilverlightApp { - public class PsychlopsMain - { - Canvas cnvs; - Rectangle[] rect; - int n; - - public void psychlops_main() - { - n = 1; - cnvs = new Canvas(500, 500); - rect = new Rectangle[n]; - for (int i = 0; i < n; i++) + public class PsychlopsMain + { + Canvas cnvs; + Image img, img2, img3; + int isize = 40; + int frames; + Psychlops.Widgets.Slider tfreq; + Psychlops.Widgets.Slider contrast; + Psychlops.Widgets.Slider lambda; + + + + public void psychlops_main() + { + cnvs = new Canvas(300, 600); + Interval rng = new Interval(); + tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0); + contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25); + lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30); + + img = new Image(isize * 2, isize * 2); + img2 = new Image(isize * 2, isize * 2); + img3 = new Image(isize * 2, isize * 2); + + var gabor1 = StaticFunctions.NewArray(100); + foreach(var g in gabor1) { - rect[i] = new Rectangle(10, 10); - rect[i].fill = Color.red; + g.setSigma(isize / 8).centering().shift(Math.random(300) - 150, Math.random(600) - 300); + g.orientation = Math.random(2*Math.PI); } - Interval rng = new Interval(); - var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100); - while (true) + while (true) { - cnvs.clear(); - for (int i = 0; i < n; i++) + cnvs.clear(new Color(0.5)); + + Figures.drawGabor(ref img, isize / 8, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); + Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); + Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); + + + //img.centering().shift(0, -isize * 1.5).draw(); + //img2.centering().draw(); + //img3.centering().shift(0, isize * 1.5).draw(); + + + foreach (var g in gabor1) { - rect[i].centering().shift(slider * i*3, i*3).draw(); + g.wavelength = lambda; + g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60; + g.contrast = contrast; + g.draw(); } - cnvs.flip(); - } - } - } -} + + if (!Mouse.left.pressed()) frames++; + cnvs.flip(); + } + } + } +} */ \ No newline at end of file