3 namespace PsychlopsSilverlightApp
\r
6 public class PsychlopsMain
\r
10 public void psychlops_main() {
\r
12 Canvas display = new Canvas(768,768);
\r
14 double rect_size = 100;
\r
15 double rect_lum = 0.5;
\r
16 double bg_lum = 0.5;
\r
17 double size = 250.0;
\r
22 int envelopemode = 0;
\r
23 double refresh = display.getRefreshRate();
\r
24 double[] SF=new double[2];
\r
31 double[] initphase = new double[2];
\r
32 double _i, _j, _x, _y, _x2, _y2, col;
\r
33 double amplitude = 1.0;
\r
35 Rectangle fixation1 = new Rectangle(3,9);
\r
36 Rectangle fixation2 = new Rectangle(9,3);
\r
37 fixation1.centering();
\r
38 fixation2.centering();
\r
39 Rectangle contrastrect = new Rectangle();
\r
40 contrastrect.set(760,760);
\r
42 Image envelope = new Image();
\r
43 Psychlops.Color bglum= new Color(0.5,0.5,0.5);
\r
44 Psychlops.Color masklum = new Color(0.5,0.5,0.5,0.5);
\r
46 Interval rng = new Interval();
\r
49 Psychlops.Widgets.Slider TF;
\r
50 TF = new Psychlops.Widgets.Slider("TF", 0.25<=rng<=2.0 , 0.1);
\r
55 Psychlops.Widgets.Slider SFs;
\r
56 SFs = new Psychlops.Widgets.Slider("SF", 4.0<=rng<=16.0 , 4.0);
\r
59 Psychlops.Widgets.Slider contrast;
\r
60 contrast= new Psychlops.Widgets.Slider("Contrast", 0.0<=rng<=1.0 , 0.1);
\r
61 contrast.value = 0.1;
\r
64 var element = StaticFunctions.NewArray<Figures.ShaderGabor>(2);
\r
65 for (int i = 0; i < element.Length; i++){
\r
66 element[i].setSigma(sigma); // set a size of patch as a halfwidth of Gaussian
\r
67 element[i].orientation = Math.PI/4.0+Math.PI/2.0*(1-i);//Math.PI/2*(rand()%2);// //set orientations
\r
73 envelope.set(size, size);
\r
74 envelope.clear(bglum);
\r
76 for(int i=0; i<size; i++){
\r
77 for(int j=0; j<size; j++){
\r
80 _x=_i*Math.cos(-Math.PI/4.0)+_j*Math.sin(-Math.PI/4.0);
\r
81 _y=-_i*Math.sin(-Math.PI/4.0)+_j*Math.cos(-Math.PI/4.0);
\r
82 col=Math.exp(-(_x*_x)/(2*Math.pow(sigma*2/6.0,2.0))-(_y*_y)/(2*Math.pow(sigma*2,2.0)));
\r
83 envelope.alpha(i,j,1.0-col);
\r
89 while(!Keyboard.esc.pushed()) {
\r
90 if(Keyboard.spc.pushed())envelopemode++; envelopemode%=2;
\r
91 Display.clear(bglum);
\r
93 //phase = fmod(phase,60);
\r
95 for(int i=0; i<2; i++) {
\r
96 element[i].phase =(SF[i]/SF[0])*amplitude*
\r
97 Math.PI*Math.sin(Math.PI/2*i+2*Math.PI*phase*TF/refresh);
\r
98 element[i].wavelength = lambda/SF[i];
\r
99 element[i].contrast = contrast;
\r
103 element[0].centering().shift(-size * 0.6, -size * 0.6);
\r
105 element[1].centering().shift(size*0.6,-size*0.6);
\r
107 element[1].centering().shift(-size*0.6,size*0.6);
\r
109 element[0].centering().shift(size*0.6,size*0.6);
\r
113 if(envelopemode>0){
\r
114 envelope.centering().shift(size*0.6,-size*0.6).draw();
\r
115 envelope.centering().shift(-size*0.6,size*0.6).draw();
\r
117 masklum.set(bg_lum, bg_lum, bg_lum, 1-contrast);
\r
118 contrastrect.centering();
\r
119 contrastrect.draw(masklum);
\r
120 fixation1.centering().shift(size*2,0.0);
\r
121 fixation1.draw(Color.red);
\r
122 fixation2.centering().shift(size*2,0.0);
\r
123 fixation2.draw(Color.red);
\r
125 Display.var(Mouse.x, 300, 300);
\r
126 Display.var(Mouse.y, 300, 320);
\r
143 //Position Bias Program
\r
144 namespace PsychlopsSilverlightApp
\r
147 public class PsychlopsMain
\r
150 Image img, img2, img3;
\r
153 Psychlops.Widgets.Slider tfreq;
\r
154 Psychlops.Widgets.Slider contrast;
\r
155 Psychlops.Widgets.Slider lambda;
\r
159 public void psychlops_main()
\r
161 cnvs = new Canvas(300, 600);
\r
162 Interval rng = new Interval();
\r
163 tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0);
\r
164 contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25);
\r
165 lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30);
\r
167 img = new Image(isize * 2, isize * 2);
\r
168 img2 = new Image(isize * 2, isize * 2);
\r
169 img3 = new Image(isize * 2, isize * 2);
\r
171 var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100);
\r
172 foreach (var g in gabor1)
\r
174 g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300);
\r
175 //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300);
\r
176 g.orientation = Math.random(2 * Math.PI);
\r
177 //g.orientation2 = Math.random(2 * Math.PI);
\r
182 cnvs.clear(new Color(0.5));
\r
184 Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);
\r
185 Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);
\r
186 Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);
\r
189 //img.centering().shift(0, -isize * 1.5).draw();
\r
190 //img2.centering().draw();
\r
191 //img3.centering().shift(0, isize * 1.5).draw();
\r
194 //foreach (var g in gabor1)
\r
195 for (int i = 0; i < gabor1.Length; i++)
\r
197 gabor1[i].wavelength = lambda;
\r
198 gabor1[i].phase = (double)frames * 2.0 * Math.PI * tfreq / 60;
\r
199 gabor1[i].contrast = contrast;
\r
200 //g.wavelength2 = lambda * 2;
\r
201 //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60;
\r
202 //g.contrast2 = contrast / 2;
\r
206 if (!Mouse.left.pressed()) frames++;
\r
216 ///+ Prefix linkto BasicCode1
\r
217 //// Lines for set up Psychlops environment
\r
220 namespace PsychlopsSilverlightApp
\r
223 public class PsychlopsMain
\r
225 ///- Prefix linkto BasicCode1
\r
229 //// Psychlops runs at the first line of this function psychlops_main().
\r
230 public void psychlops_main()
\r
234 ////Prepare global parameters
\r
235 Rectangle p1 = new Rectangle(1,1);
\r
236 Color col1 = new Color();
\r
240 double lmean=0.25, contrast = 0.5;
\r
244 Canvas disp = new Canvas(Canvas.window, Display.secondary);
\r
246 var fieldW_ = Psychlops.Widgets.Browser.Element.byID("fieldW");
\r
247 var fieldH_ = Psychlops.Widgets.Browser.Element.byID("fieldH");
\r
248 var wL_ = Psychlops.Widgets.Browser.Element.byID("wL");
\r
249 var Cont_ = Psychlops.Widgets.Browser.Element.byID("Cont");
\r
250 var ix_ = Psychlops.Widgets.Browser.Element.byID("ix");
\r
251 var iy_ = Psychlops.Widgets.Browser.Element.byID("iy");
\r
252 var gap_ = Psychlops.Widgets.Browser.Element.byID("gap");
\r
257 p1.centering().shift(-width*0.5 + x0, -height*0.5 + y0); //Move a point to the initial position.
\r
261 ////drawing objects
\r
262 for(int i=0; i < width; i++)
\r
264 col1.set(lmean*((contrast*Math.sin((2*Math.PI*i/lambda)))+1)); //Set a color.
\r
266 ///+ 2.1 Drawing a column
\r
267 ////drawing a column
\r
268 for(int j=0;j < height; j++)
\r
271 p1.shift(0, pitch);
\r
273 ///- 2.1 Drawing a column
\r
275 p1.shift(1, -height * pitch); //back to vertical intitial point after drawing one column.
\r
280 while (!Keyboard.spc.pushed()) { }; //Wait until space key is pressed.
\r
292 //// Lines for set up Psychlops environment
\r
295 namespace PsychlopsSilverlightApp
\r
298 public class PsychlopsMain
\r
304 //// Psychlops runs at the first line of this function psychlops_main().
\r
305 public void psychlops_main()
\r
307 Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.
\r
309 var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
310 var SIZE_X_ = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
311 var SIZE_Y_ = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
312 var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
313 var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
314 var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
315 var COLOR_BG = Psychlops.Widgets.Browser.Element.byID("COLOR_BG");
\r
316 var Period_Size = Psychlops.Widgets.Browser.Element.byID("Period_Size");
\r
317 var Period_Position = Psychlops.Widgets.Browser.Element.byID("Period_Position");
\r
318 var Speed_HSize_ = Psychlops.Widgets.Browser.Element.byID("Speed_HSize");
\r
319 var Speed_VSize = Psychlops.Widgets.Browser.Element.byID("Speed_VSize");
\r
320 var Speed_VMotion = Psychlops.Widgets.Browser.Element.byID("Speed_VMotion");
\r
321 double SIZE_X = SIZE_X_, SIZE_Y = SIZE_Y_;
\r
324 //// Set a figure size, position and color.
\r
325 Rectangle figure = new Rectangle();
\r
326 Ellipse figure2 = new Ellipse();
\r
327 figure.set(SIZE_X_, SIZE_Y_); // Set the size of figure.
\r
328 figure2.set(SIZE_X_, SIZE_Y_); // Set the size of figure.
\r
329 figure.centering().shift(0, 0); // Move the figure to the starting point.
\r
330 figure2.centering().shift(0, 0); // Move the figure to the starting point.
\r
334 int looming_direction = 1, motion_dir = 1;
\r
335 double direction = 1.0;
\r
336 //looming_direction is a variable for size change.
\r
337 //motion_dir is a variable for motion direction.
\r
338 ///+ 3 Drawing loop
\r
339 //// Draw each frames in a "while loop".
\r
340 while (!Keyboard.esc.pushed())
\r
341 { //exit a program when the escape key is pressed down.
\r
342 window.clear(COLOR_BG); // Clear the window with a designated gray-scale level.
\r
345 //// Calculate object's position and size for each frame.
\r
347 if (frame % Period_Size == 0)
\r
348 { // a direction of size change will reverse at designated frames.
\r
349 looming_direction = looming_direction * -1;
\r
352 if (frame % Period_Position == 0)
\r
353 { // motion direction will reverse at designated frames.
\r
360 //// Settting figure's properties
\r
361 figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
362 figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".
\r
363 figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
364 figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
365 figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".
\r
366 figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
368 figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
369 figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".
\r
370 figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
371 figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
372 figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".
\r
373 figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
379 if ("Rectangle".Equals(FIGURE))
\r
381 figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.
\r
385 figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.
\r
387 window.flip(); // Reflect the drawing for the display by flipping frame buffers.
\r
391 ////make a step for next frames
\r
395 ///- 3 Drawing loop
\r
408 //The reversed-phi motion.
\r
410 //Phi movement as a subtraction process. Vision Res 10:1411?1430
\r
413 //// Include Psychlops Package
\r
416 namespace PsychlopsSilverlightApp
\r
419 public class PsychlopsMain
\r
424 ///+ Stimulus drawing function
\r
425 //// A function for stimulus drawing (main body)
\r
426 void RectLuminance()
\r
430 //// Declare and initialize local variables
\r
431 double rect_size = 20;
\r
433 double bg_lum = 0.5;
\r
434 double radii = 200;
\r
436 int element_number = 25;
\r
437 int radial_row = 5;
\r
439 double rotation_tf = 0.2;
\r
440 double polarity = 1;
\r
443 double contrastflag = 1;
\r
447 Canvas display = new Canvas(Canvas.window); //Prepare drawing window
\r
448 refresh = Display.getRefreshRate();
\r
450 Ellipse rect = new Ellipse();
\r
451 rect.set(rect_size, rect_size);
\r
453 Ellipse fixation = new Ellipse(5, 5);
\r
454 fixation.centering();
\r
456 Letters let1 = new Letters("Press Space key to change stimulus type");
\r
457 let1.centering().shift(-180, 220);
\r
458 Letters let2 = new Letters("Phi");
\r
459 let2.centering().shift(-10, 200);
\r
460 Letters let3 = new Letters("Reversed-Phi");
\r
461 let3.centering().shift(-60, 200);
\r
463 rotation = Math.random(2 * Math.PI);
\r
465 ///+ user interface
\r
466 ////register variables to demo circumstances
\r
467 Interval rng = new Interval();
\r
469 Psychlops.Widgets.Slider rect_contrast;
\r
470 rect_contrast = new Psychlops.Widgets.Slider("Contrast", 0.1 <= rng <= 1.0, 0.1);
\r
471 rect_contrast.value = 0.5;
\r
472 ///- user interface
\r
478 //AppState::setThreadPriority(AppState::HIGH);
\r
482 if (Keyboard.spc.pushed()) contrastflag = -contrastflag;
\r
483 if (contrastflag < 0) polarity = -polarity;
\r
484 rotation = 2 * Math.PI * rotation_tf * frame * period / refresh;
\r
486 for (int frame_now = 0; frame_now < period; frame_now++)
\r
488 Display.clear(new Color(bg_lum));
\r
489 for (int j = 0; j < radial_row; j++)
\r
491 rect.resize(rect_size * (j + radial_row) / 10.0, rect_size * (j + radial_row) / 10.0);
\r
492 for (double i = 0; i < element_number; i++)
\r
494 rect_lum = bg_lum * (1.0 + polarity * rect_contrast);
\r
495 rect.centering().shift(radii * (j + radial_row) / 10.0 * Math.cos(rotation + i * 2 * Math.PI / element_number), radii * (j + radial_row) / 10.0 * Math.sin(rotation + i * 2 * Math.PI / element_number));
\r
496 rect.draw(rect_lum);
\r
499 fixation.draw(Color.red);
\r
501 if (contrastflag > 0) let2.draw();
\r
507 //AppState::setThreadPriority(AppState::NORMAL);
\r
509 ///- Stimulus drawing function
\r
511 ///+ Main function for demo circumstances
\r
512 //// Psychlops Main function
\r
513 public void psychlops_main()
\r
515 ///+ Demo circumstances
\r
516 //// Spells for run demonstration circumstances
\r
517 Procedure p = new Procedure();
\r
518 //p.setDesign(Procedure::DEMO); //Designate that this is a demo.
\r
519 p.setProcedure(RectLuminance); //The argument name is a name of drawing function.
\r
521 ///- Demo circumstances
\r
523 ///- Main function for demo circumstances
\r
532 //Two types of plaid motion
\r
533 //E. H. Adelson and J. A. Movshon (1982).
\r
534 //Phenomenal coherence of moving visual patterns. Nature 300, 523-525
\r
537 //// Include Psychlops Package
\r
540 namespace PsychlopsSilverlightApp
\r
543 public class PsychlopsMain
\r
548 // Struct for component paremeters
\r
551 public double contrast;
\r
552 public double orientation;
\r
553 public double lambda;
\r
558 ///+ Stimulus drawing function
\r
559 //// A function for stimulus drawing (main body)
\r
560 void drawgratingmovie(Image[] img, component c1, component c2, double contrast, int start, int maxframe, double bg_lum, double alpha)
\r
562 double _xp, _xp2, col1, col2;
\r
563 double contrast1, contrast2;
\r
564 double imageheight, imagewidth;
\r
566 contrast1 = contrast*c1.contrast/(c1.contrast+c2.contrast);
\r
567 contrast2 = contrast*c2.contrast/(c1.contrast+c2.contrast);
\r
569 imageheight = img[0].getHeight();
\r
570 imagewidth = img[0].getWidth();
\r
572 for(int frame=start; frame<start+maxframe+1; frame++){
\r
573 //Display.progressbar(frame, maxframe+1);
\r
574 //img[frame].convert(Image::RGBA);
\r
575 for(int i=0; i<imagewidth; i++){
\r
576 for(int j=0; j<imageheight; j++){
\r
577 _xp = Math.sin(c1.orientation)*(i-imagewidth*0.5) + Math.cos(c1.orientation) * (j-imageheight *0.5);
\r
578 _xp2 = Math.sin(c2.orientation)*(i-imagewidth*0.5) + Math.cos(c2.orientation) * (j-imageheight *0.5);
\r
579 col1 = bg_lum*contrast1*Math.sin(2*Math.PI*_xp/c1.lambda + 2*Math.PI*c1.tf*frame/(double)refresh);
\r
580 col2 = bg_lum*contrast2*Math.sin(2*Math.PI*_xp2/c2.lambda + 2*Math.PI*c2.tf*frame/(double)refresh);
\r
581 img[frame].pix(i,j,new Color(col1+col2+bg_lum));
\r
582 img[frame].alpha(i,j,alpha);
\r
585 //img[frame].cache();
\r
589 ///+ Stimulus drawing function
\r
590 //// A function for stimulus drawing (main body)
\r
592 Canvas display = new Canvas(Canvas.window);
\r
594 //// Declare and initialize local variables
\r
595 int rect_size = 150;
\r
596 double rect_lum = 0.5;
\r
597 double bg_lum = 0.2;
\r
598 double duration = 400;
\r
600 double[] lambda = new double[2], contrast = new double[2], tf = new double[2];
\r
601 double center_orientation = 0.0;
\r
602 Image[,] movie = StaticFunctions.NewArray<Image>(2, 120);
\r
603 Image[,] component_movie = StaticFunctions.NewArray<Image>(4, 120);
\r
604 Image envelope = new Image(), envelope_small = new Image();
\r
606 for(int i=0; i<120; i++)
\r
608 movie[0, i].set(rect_size, rect_size);
\r
609 movie[1, i].set(rect_size, rect_size);
\r
610 component_movie[0, i].set(rect_size/2, rect_size/2);
\r
611 component_movie[1, i].set(rect_size/2, rect_size/2);
\r
612 component_movie[2, i].set(rect_size/2, rect_size/2);
\r
613 component_movie[3, i].set(rect_size/2, rect_size/2);
\r
615 envelope.set(rect_size, rect_size);
\r
616 envelope_small.set(rect_size/2, rect_size/2);
\r
618 Letters let1 = new Letters(), let2 = new Letters(), let3 = new Letters();
\r
619 let1.str = "Component1";
\r
620 let2.str = "Component2";
\r
621 let3.str = "Superposition";
\r
622 let1.centering().shift(-rect_size*1.25, -rect_size);
\r
624 let2.centering().shift(rect_size*1.25, -rect_size);
\r
626 let3.centering().shift(0.0, rect_size*0.75);
\r
629 component c1, c2, c0;
\r
630 c0 = new component{ 0.0,0.0,1.0,1.0 }; //dummy for component movie
\r
632 // Prepare Type-I plaid movie
\r
633 center_orientation = 0.0;
\r
634 orientation_offset = Math.PI/6;
\r
635 contrast[0] = 1.0, contrast[1] = 1.0;
\r
636 lambda[0] = 30.0, lambda[1] = 30.0;
\r
637 tf[0] = 1.0; tf[1] = 1.0;
\r
639 c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};
\r
640 c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};
\r
642 drawgratingmovie(movie[0],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
643 drawgratingmovie(component_movie[0],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
644 drawgratingmovie(component_movie[1],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
648 // Prepare Type-II plaid movie
\r
649 center_orientation = -0.0, orientation_offset = Math.PI/12;
\r
650 contrast[0] = 1.0, contrast[1] = 1.0;
\r
651 lambda[0] = 30.0, lambda[1] = 30.0;
\r
652 tf[0] = 1.0; tf[1] = 4.0;
\r
654 c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};
\r
655 c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};
\r
657 drawgratingmovie(movie[1],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
658 drawgratingmovie(component_movie[2],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
659 drawgratingmovie(component_movie[3],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
663 //draw Gaussian envelopes
\r
664 envelope.clear(new Color(bg_lum)); //clear offscreen image
\r
666 for(int i=0; i<rect_size; i++){
\r
667 _x=i-0.5*rect_size;
\r
668 for(int j=0; j<rect_size; j++){
\r
669 _y=j-0.5*rect_size;
\r
670 envelope.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/6.0, 2.0) ))));
\r
674 envelope_small.clear(new Color(bg_lum)); //clear offscreen image
\r
675 for(int i=0; i<rect_size*0.5; i++){
\r
676 _x=i-0.25*rect_size;
\r
677 for(int j=0; j<rect_size*0.5; j++){
\r
678 _y=j-0.25*rect_size;
\r
679 envelope_small.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/12.0, 2.0) ))));
\r
682 envelope.cache(); //send offscreen image from main memory to GPU
\r
683 envelope_small.cache(); //send offscreen image from main memory to GPU
\r
686 ///+ user interface
\r
687 // Draw user interface
\r
688 Widgets::SelectBox stimulus_type;
\r
689 stimulus_type.area.set(120, 20);
\r
690 stimulus_type.append(L"TypeI");
\r
691 stimulus_type.append(L"TypeII");
\r
692 stimulus_type.centering().shift(-120.0,250.0);
\r
694 Psychlops::Widgets::SelectBox stimulus_type2;
\r
695 stimulus_type2.area.set(120, 20);
\r
696 stimulus_type2.append(L"Continuous");
\r
697 stimulus_type2.append(L"Periodic");
\r
698 stimulus_type2.centering().shift(120.0,250.0);
\r
700 Psychlops::Widgets::Slider duration_slider;
\r
701 duration_slider.area.set(100,20);
\r
702 duration_slider.centering().shift(120,280.0);
\r
703 Interval rng = new Interval();
\r
704 duration_slider.link(duration, 50<=rng<=950, 50.0, 50.0);
\r
705 ///- user interface
\r
710 int period = refresh_int;
\r
712 while(!Keyboard.esc.pushed()) {
\r
713 Display.clear(new Color(bg_lum));
\r
714 movienum = stimulus_type.getSelected(); //if "Type-I" is selected, 0, else frame refresh per sec
\r
717 else period = refresh_int;
\r
720 movie[movienum, frame].centering().draw();
\r
721 envelope.centering().draw();
\r
722 component_movie[movienum*2, frame].centering().shift(-rect_size*0.5, -rect_size).draw();
\r
723 envelope_small.centering().shift(-rect_size*0.5, -rect_size).draw();
\r
724 component_movie[movienum*2+1, frame].centering().shift(rect_size*0.5, -rect_size).draw();
\r
725 envelope_small.centering().shift(rect_size*0.5, -rect_size).draw();
\r
728 ///+ draw user interface
\r
732 stimulus_type.draw();
\r
733 stimulus_type2.draw();
\r
734 if(stimulus_type2.getSelected())duration_slider.draw();
\r
735 ///- draw user interface
\r
737 if(frame++ >= period) frame -= refresh_int;
\r
742 ///- Stimulus drawing function
\r
744 ///+ Main function for demo circumstances
\r
745 public void psychlops_main() {
\r
746 ///+ Demo circumstances
\r
747 //// Spells for run demonstration circumstances
\r
748 Procedure p = new Procedure();
\r
749 //p.setDesign(Procedure::DEMO); //Designate that this is a demo.
\r
750 p.setProcedure(drawplaid); //The argument name is a name of drawing function.
\r
752 ///- Demo circumstances
\r