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
140 //Position Bias Program
\r
141 namespace PsychlopsSilverlightApp
\r
144 public class PsychlopsMain
\r
147 Image img, img2, img3;
\r
150 Psychlops.Widgets.Slider tfreq;
\r
151 Psychlops.Widgets.Slider contrast;
\r
152 Psychlops.Widgets.Slider lambda;
\r
156 public void psychlops_main()
\r
158 cnvs = new Canvas(300, 600);
\r
159 Interval rng = new Interval();
\r
160 tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0);
\r
161 contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25);
\r
162 lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30);
\r
164 img = new Image(isize * 2, isize * 2);
\r
165 img2 = new Image(isize * 2, isize * 2);
\r
166 img3 = new Image(isize * 2, isize * 2);
\r
168 var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100);
\r
169 foreach (var g in gabor1)
\r
171 g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300);
\r
172 //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300);
\r
173 g.orientation = Math.random(2 * Math.PI);
\r
174 //g.orientation2 = Math.random(2 * Math.PI);
\r
179 cnvs.clear(new Color(0.5));
\r
181 Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);
\r
182 Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);
\r
183 Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);
\r
186 //img.centering().shift(0, -isize * 1.5).draw();
\r
187 //img2.centering().draw();
\r
188 //img3.centering().shift(0, isize * 1.5).draw();
\r
191 //foreach (var g in gabor1)
\r
192 for (int i = 0; i < gabor1.Length; i++)
\r
194 gabor1[i].wavelength = lambda;
\r
195 gabor1[i].phase = (double)frames * 2.0 * Math.PI * tfreq / 60;
\r
196 gabor1[i].contrast = contrast;
\r
197 //g.wavelength2 = lambda * 2;
\r
198 //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60;
\r
199 //g.contrast2 = contrast / 2;
\r
203 if (!Mouse.left.pressed()) frames++;
\r
213 ///+ Prefix linkto BasicCode1
\r
214 //// Lines for set up Psychlops environment
\r
217 namespace PsychlopsSilverlightApp
\r
220 public class PsychlopsMain
\r
222 ///- Prefix linkto BasicCode1
\r
226 //// Psychlops runs at the first line of this function psychlops_main().
\r
227 public void psychlops_main()
\r
231 ////Prepare global parameters
\r
232 Rectangle p1 = new Rectangle(1,1);
\r
233 Color col1 = new Color();
\r
237 double lmean=0.25, contrast = 0.5;
\r
241 Canvas disp = new Canvas(Canvas.window, Display.secondary);
\r
243 var fieldW_ = Psychlops.Widgets.Browser.Element.byID("fieldW");
\r
244 var fieldH_ = Psychlops.Widgets.Browser.Element.byID("fieldH");
\r
245 var wL_ = Psychlops.Widgets.Browser.Element.byID("wL");
\r
246 var Cont_ = Psychlops.Widgets.Browser.Element.byID("Cont");
\r
247 var ix_ = Psychlops.Widgets.Browser.Element.byID("ix");
\r
248 var iy_ = Psychlops.Widgets.Browser.Element.byID("iy");
\r
249 var gap_ = Psychlops.Widgets.Browser.Element.byID("gap");
\r
254 p1.centering().shift(-width*0.5 + x0, -height*0.5 + y0); //Move a point to the initial position.
\r
258 ////drawing objects
\r
259 for(int i=0; i < width; i++)
\r
261 col1.set(lmean*((contrast*Math.sin((2*Math.PI*i/lambda)))+1)); //Set a color.
\r
263 ///+ 2.1 Drawing a column
\r
264 ////drawing a column
\r
265 for(int j=0;j < height; j++)
\r
268 p1.shift(0, pitch);
\r
270 ///- 2.1 Drawing a column
\r
272 p1.shift(1, -height * pitch); //back to vertical intitial point after drawing one column.
\r
277 while (!Keyboard.spc.pushed()) { }; //Wait until space key is pressed.
\r
289 //// Lines for set up Psychlops environment
\r
292 namespace PsychlopsSilverlightApp
\r
295 public class PsychlopsMain
\r
301 //// Psychlops runs at the first line of this function psychlops_main().
\r
302 public void psychlops_main()
\r
304 Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.
\r
306 var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE");
\r
307 var SIZE_X_ = Psychlops.Widgets.Browser.Element.byID("SIZE_X");
\r
308 var SIZE_Y_ = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");
\r
309 var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R");
\r
310 var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G");
\r
311 var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B");
\r
312 var COLOR_BG = Psychlops.Widgets.Browser.Element.byID("COLOR_BG");
\r
313 var Period_Size = Psychlops.Widgets.Browser.Element.byID("Period_Size");
\r
314 var Period_Position = Psychlops.Widgets.Browser.Element.byID("Period_Position");
\r
315 var Speed_HSize_ = Psychlops.Widgets.Browser.Element.byID("Speed_HSize");
\r
316 var Speed_VSize = Psychlops.Widgets.Browser.Element.byID("Speed_VSize");
\r
317 var Speed_VMotion = Psychlops.Widgets.Browser.Element.byID("Speed_VMotion");
\r
318 double SIZE_X = SIZE_X_, SIZE_Y = SIZE_Y_;
\r
321 //// Set a figure size, position and color.
\r
322 Rectangle figure = new Rectangle();
\r
323 Ellipse figure2 = new Ellipse();
\r
324 figure.set(SIZE_X_, SIZE_Y_); // Set the size of figure.
\r
325 figure2.set(SIZE_X_, SIZE_Y_); // Set the size of figure.
\r
326 figure.centering().shift(0, 0); // Move the figure to the starting point.
\r
327 figure2.centering().shift(0, 0); // Move the figure to the starting point.
\r
331 int looming_direction = 1, motion_dir = 1;
\r
332 double direction = 1.0;
\r
333 //looming_direction is a variable for size change.
\r
334 //motion_dir is a variable for motion direction.
\r
335 ///+ 3 Drawing loop
\r
336 //// Draw each frames in a "while loop".
\r
337 while (!Keyboard.esc.pushed())
\r
338 { //exit a program when the escape key is pressed down.
\r
339 window.clear(COLOR_BG); // Clear the window with a designated gray-scale level.
\r
342 //// Calculate object's position and size for each frame.
\r
344 if (frame % Period_Size == 0)
\r
345 { // a direction of size change will reverse at designated frames.
\r
346 looming_direction = looming_direction * -1;
\r
349 if (frame % Period_Position == 0)
\r
350 { // motion direction will reverse at designated frames.
\r
357 //// Settting figure's properties
\r
358 figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
359 figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".
\r
360 figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
361 figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
362 figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".
\r
363 figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
365 figure.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
366 figure.getHeight() + looming_direction * 1);// Scaling the figure in a direction given by "looming_direction".
\r
367 figure.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
368 figure2.resize(figure.getWidth() + looming_direction * 1, // Scaling the figure in a direction given by "looming_direction".
\r
369 figure.getHeight() + direction * Speed_VSize);// Scaling the figure in a direction given by "looming_direction".
\r
370 figure2.shift(motion_dir * 1.0, motion_dir * Speed_VMotion);// Move the figure for 1 pixel in direction given by "motion_dir".
\r
376 if ("Rectangle".Equals(FIGURE))
\r
378 figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.
\r
382 figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the figure with a designated color at designated position.
\r
384 window.flip(); // Reflect the drawing for the display by flipping frame buffers.
\r
388 ////make a step for next frames
\r
392 ///- 3 Drawing loop
\r
405 //The reversed-phi motion.
\r
407 //Phi movement as a subtraction process. Vision Res 10:1411?1430
\r
410 //// Include Psychlops Package
\r
413 namespace PsychlopsSilverlightApp
\r
416 public class PsychlopsMain
\r
421 ///+ Stimulus drawing function
\r
422 //// A function for stimulus drawing (main body)
\r
423 void RectLuminance()
\r
427 //// Declare and initialize local variables
\r
428 double rect_size = 20;
\r
430 double bg_lum = 0.5;
\r
431 double radii = 200;
\r
433 int element_number = 25;
\r
434 int radial_row = 5;
\r
436 double rotation_tf = 0.2;
\r
437 double polarity = 1;
\r
440 double contrastflag = 1;
\r
444 Canvas display = new Canvas(Canvas.window); //Prepare drawing window
\r
445 refresh = Display.getRefreshRate();
\r
447 Ellipse rect = new Ellipse();
\r
448 rect.set(rect_size, rect_size);
\r
450 Ellipse fixation = new Ellipse(5, 5);
\r
451 fixation.centering();
\r
453 Letters let1 = new Letters("Press Space key to change stimulus type");
\r
454 let1.centering().shift(-180, 220);
\r
455 Letters let2 = new Letters("Phi");
\r
456 let2.centering().shift(-10, 200);
\r
457 Letters let3 = new Letters("Reversed-Phi");
\r
458 let3.centering().shift(-60, 200);
\r
460 rotation = Math.random(2 * Math.PI);
\r
462 ///+ user interface
\r
463 ////register variables to demo circumstances
\r
464 Interval rng = new Interval();
\r
466 Psychlops.Widgets.Slider rect_contrast;
\r
467 rect_contrast = new Psychlops.Widgets.Slider("Contrast", 0.1 <= rng <= 1.0, 0.1);
\r
468 rect_contrast.value = 0.5;
\r
469 ///- user interface
\r
475 //AppState::setThreadPriority(AppState::HIGH);
\r
479 if (Keyboard.spc.pushed()) contrastflag = -contrastflag;
\r
480 if (contrastflag < 0) polarity = -polarity;
\r
481 rotation = 2 * Math.PI * rotation_tf * frame * period / refresh;
\r
483 for (int frame_now = 0; frame_now < period; frame_now++)
\r
485 Display.clear(new Color(bg_lum));
\r
486 for (int j = 0; j < radial_row; j++)
\r
488 rect.resize(rect_size * (j + radial_row) / 10.0, rect_size * (j + radial_row) / 10.0);
\r
489 for (double i = 0; i < element_number; i++)
\r
491 rect_lum = bg_lum * (1.0 + polarity * rect_contrast);
\r
492 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
493 rect.draw(rect_lum);
\r
496 fixation.draw(Color.red);
\r
498 if (contrastflag > 0) let2.draw();
\r
504 //AppState::setThreadPriority(AppState::NORMAL);
\r
506 ///- Stimulus drawing function
\r
508 ///+ Main function for demo circumstances
\r
509 //// Psychlops Main function
\r
510 public void psychlops_main()
\r
512 ///+ Demo circumstances
\r
513 //// Spells for run demonstration circumstances
\r
514 Procedure p = new Procedure();
\r
515 //p.setDesign(Procedure::DEMO); //Designate that this is a demo.
\r
516 p.setProcedure(RectLuminance); //The argument name is a name of drawing function.
\r
518 ///- Demo circumstances
\r
520 ///- Main function for demo circumstances
\r
529 //Two types of plaid motion
\r
530 //E. H. Adelson and J. A. Movshon (1982).
\r
531 //Phenomenal coherence of moving visual patterns. Nature 300, 523-525
\r
534 //// Include Psychlops Package
\r
537 namespace PsychlopsSilverlightApp
\r
540 public class PsychlopsMain
\r
545 // Struct for component paremeters
\r
548 public double contrast;
\r
549 public double orientation;
\r
550 public double lambda;
\r
555 ///+ Stimulus drawing function
\r
556 //// A function for stimulus drawing (main body)
\r
557 void drawgratingmovie(Image[] img, component c1, component c2, double contrast, int start, int maxframe, double bg_lum, double alpha)
\r
559 double _xp, _xp2, col1, col2;
\r
560 double contrast1, contrast2;
\r
561 double imageheight, imagewidth;
\r
563 contrast1 = contrast*c1.contrast/(c1.contrast+c2.contrast);
\r
564 contrast2 = contrast*c2.contrast/(c1.contrast+c2.contrast);
\r
566 imageheight = img[0].getHeight();
\r
567 imagewidth = img[0].getWidth();
\r
569 for(int frame=start; frame<start+maxframe+1; frame++){
\r
570 //Display.progressbar(frame, maxframe+1);
\r
571 //img[frame].convert(Image::RGBA);
\r
572 for(int i=0; i<imagewidth; i++){
\r
573 for(int j=0; j<imageheight; j++){
\r
574 _xp = Math.sin(c1.orientation)*(i-imagewidth*0.5) + Math.cos(c1.orientation) * (j-imageheight *0.5);
\r
575 _xp2 = Math.sin(c2.orientation)*(i-imagewidth*0.5) + Math.cos(c2.orientation) * (j-imageheight *0.5);
\r
576 col1 = bg_lum*contrast1*Math.sin(2*Math.PI*_xp/c1.lambda + 2*Math.PI*c1.tf*frame/(double)refresh);
\r
577 col2 = bg_lum*contrast2*Math.sin(2*Math.PI*_xp2/c2.lambda + 2*Math.PI*c2.tf*frame/(double)refresh);
\r
578 img[frame].pix(i,j,new Color(col1+col2+bg_lum));
\r
579 img[frame].alpha(i,j,alpha);
\r
582 //img[frame].cache();
\r
586 ///+ Stimulus drawing function
\r
587 //// A function for stimulus drawing (main body)
\r
589 Canvas display = new Canvas(Canvas.window);
\r
591 //// Declare and initialize local variables
\r
592 int rect_size = 150;
\r
593 double rect_lum = 0.5;
\r
594 double bg_lum = 0.2;
\r
595 double duration = 400;
\r
597 double[] lambda = new double[2], contrast = new double[2], tf = new double[2];
\r
598 double center_orientation = 0.0;
\r
599 Image[,] movie = StaticFunctions.NewArray<Image>(2, 120);
\r
600 Image[,] component_movie = StaticFunctions.NewArray<Image>(4, 120);
\r
601 Image envelope = new Image(), envelope_small = new Image();
\r
603 for(int i=0; i<120; i++)
\r
605 movie[0, i].set(rect_size, rect_size);
\r
606 movie[1, i].set(rect_size, rect_size);
\r
607 component_movie[0, i].set(rect_size/2, rect_size/2);
\r
608 component_movie[1, i].set(rect_size/2, rect_size/2);
\r
609 component_movie[2, i].set(rect_size/2, rect_size/2);
\r
610 component_movie[3, i].set(rect_size/2, rect_size/2);
\r
612 envelope.set(rect_size, rect_size);
\r
613 envelope_small.set(rect_size/2, rect_size/2);
\r
615 Letters let1 = new Letters(), let2 = new Letters(), let3 = new Letters();
\r
616 let1.str = "Component1";
\r
617 let2.str = "Component2";
\r
618 let3.str = "Superposition";
\r
619 let1.centering().shift(-rect_size*1.25, -rect_size);
\r
621 let2.centering().shift(rect_size*1.25, -rect_size);
\r
623 let3.centering().shift(0.0, rect_size*0.75);
\r
626 component c1, c2, c0;
\r
627 c0 = new component{ 0.0,0.0,1.0,1.0 }; //dummy for component movie
\r
629 // Prepare Type-I plaid movie
\r
630 center_orientation = 0.0;
\r
631 orientation_offset = Math.PI/6;
\r
632 contrast[0] = 1.0, contrast[1] = 1.0;
\r
633 lambda[0] = 30.0, lambda[1] = 30.0;
\r
634 tf[0] = 1.0; tf[1] = 1.0;
\r
636 c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};
\r
637 c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};
\r
639 drawgratingmovie(movie[0],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
640 drawgratingmovie(component_movie[0],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
641 drawgratingmovie(component_movie[1],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
645 // Prepare Type-II plaid movie
\r
646 center_orientation = -0.0, orientation_offset = Math.PI/12;
\r
647 contrast[0] = 1.0, contrast[1] = 1.0;
\r
648 lambda[0] = 30.0, lambda[1] = 30.0;
\r
649 tf[0] = 1.0; tf[1] = 4.0;
\r
651 c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};
\r
652 c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};
\r
654 drawgratingmovie(movie[1],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
655 drawgratingmovie(component_movie[2],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
656 drawgratingmovie(component_movie[3],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);
\r
660 //draw Gaussian envelopes
\r
661 envelope.clear(new Color(bg_lum)); //clear offscreen image
\r
663 for(int i=0; i<rect_size; i++){
\r
664 _x=i-0.5*rect_size;
\r
665 for(int j=0; j<rect_size; j++){
\r
666 _y=j-0.5*rect_size;
\r
667 envelope.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/6.0, 2.0) ))));
\r
671 envelope_small.clear(new Color(bg_lum)); //clear offscreen image
\r
672 for(int i=0; i<rect_size*0.5; i++){
\r
673 _x=i-0.25*rect_size;
\r
674 for(int j=0; j<rect_size*0.5; j++){
\r
675 _y=j-0.25*rect_size;
\r
676 envelope_small.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/12.0, 2.0) ))));
\r
679 envelope.cache(); //send offscreen image from main memory to GPU
\r
680 envelope_small.cache(); //send offscreen image from main memory to GPU
\r
683 ///+ user interface
\r
684 // Draw user interface
\r
685 Widgets::SelectBox stimulus_type;
\r
686 stimulus_type.area.set(120, 20);
\r
687 stimulus_type.append(L"TypeI");
\r
688 stimulus_type.append(L"TypeII");
\r
689 stimulus_type.centering().shift(-120.0,250.0);
\r
691 Psychlops::Widgets::SelectBox stimulus_type2;
\r
692 stimulus_type2.area.set(120, 20);
\r
693 stimulus_type2.append(L"Continuous");
\r
694 stimulus_type2.append(L"Periodic");
\r
695 stimulus_type2.centering().shift(120.0,250.0);
\r
697 Psychlops::Widgets::Slider duration_slider;
\r
698 duration_slider.area.set(100,20);
\r
699 duration_slider.centering().shift(120,280.0);
\r
700 Interval rng = new Interval();
\r
701 duration_slider.link(duration, 50<=rng<=950, 50.0, 50.0);
\r
702 ///- user interface
\r
707 int period = refresh_int;
\r
709 while(!Keyboard.esc.pushed()) {
\r
710 Display.clear(new Color(bg_lum));
\r
711 movienum = stimulus_type.getSelected(); //if "Type-I" is selected, 0, else frame refresh per sec
\r
714 else period = refresh_int;
\r
717 movie[movienum, frame].centering().draw();
\r
718 envelope.centering().draw();
\r
719 component_movie[movienum*2, frame].centering().shift(-rect_size*0.5, -rect_size).draw();
\r
720 envelope_small.centering().shift(-rect_size*0.5, -rect_size).draw();
\r
721 component_movie[movienum*2+1, frame].centering().shift(rect_size*0.5, -rect_size).draw();
\r
722 envelope_small.centering().shift(rect_size*0.5, -rect_size).draw();
\r
725 ///+ draw user interface
\r
729 stimulus_type.draw();
\r
730 stimulus_type2.draw();
\r
731 if(stimulus_type2.getSelected())duration_slider.draw();
\r
732 ///- draw user interface
\r
734 if(frame++ >= period) frame -= refresh_int;
\r
739 ///- Stimulus drawing function
\r
741 ///+ Main function for demo circumstances
\r
742 public void psychlops_main() {
\r
743 ///+ Demo circumstances
\r
744 //// Spells for run demonstration circumstances
\r
745 Procedure p = new Procedure();
\r
746 //p.setDesign(Procedure::DEMO); //Designate that this is a demo.
\r
747 p.setProcedure(drawplaid); //The argument name is a name of drawing function.
\r
749 ///- Demo circumstances
\r