+ drawgratingmovie(movie[0],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ drawgratingmovie(component_movie[0],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ drawgratingmovie(component_movie[1],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ ///- type-I\r
+\r
+ ///+ type-II\r
+ // Prepare Type-II plaid movie\r
+ center_orientation = -0.0, orientation_offset = Math.PI/12;\r
+ contrast[0] = 1.0, contrast[1] = 1.0;\r
+ lambda[0] = 30.0, lambda[1] = 30.0;\r
+ tf[0] = 1.0; tf[1] = 4.0;\r
+\r
+ c1 = {contrast[0], center_orientation-orientation_offset, lambda[0], tf[0]};\r
+ c2 = {contrast[1], center_orientation+orientation_offset, lambda[1], tf[1]};\r
+\r
+ drawgratingmovie(movie[1],c1, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ drawgratingmovie(component_movie[2],c0, c2, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ drawgratingmovie(component_movie[3],c1, c0, 0.5, 0, refresh_int, bg_lum, 1.0);\r
+ ///- type-II\r
+\r
+ ///+ gaussian\r
+ //draw Gaussian envelopes\r
+ envelope.clear(new Color(bg_lum)); //clear offscreen image\r
+ double _x, _y;\r
+ for(int i=0; i<rect_size; i++){\r
+ _x=i-0.5*rect_size;\r
+ for(int j=0; j<rect_size; j++){\r
+ _y=j-0.5*rect_size;\r
+ envelope.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/6.0, 2.0) ))));\r
+ }\r
+ }\r
+\r
+ envelope_small.clear(new Color(bg_lum)); //clear offscreen image\r
+ for(int i=0; i<rect_size*0.5; i++){\r
+ _x=i-0.25*rect_size;\r
+ for(int j=0; j<rect_size*0.5; j++){\r
+ _y=j-0.25*rect_size;\r
+ envelope_small.alpha(i,j,1.0-Math.exp(-((_x*_x+_y*_y)/ (2.0*pow(rect_size/12.0, 2.0) ))));\r
+ }\r
+ }\r
+ envelope.cache(); //send offscreen image from main memory to GPU\r
+ envelope_small.cache(); //send offscreen image from main memory to GPU\r
+ ///- gaussian\r
+\r
+ ///+ user interface\r
+ // Draw user interface\r
+ Widgets::SelectBox stimulus_type;\r
+ stimulus_type.area.set(120, 20);\r
+ stimulus_type.append(L"TypeI");\r
+ stimulus_type.append(L"TypeII");\r
+ stimulus_type.centering().shift(-120.0,250.0);\r
+\r
+ Psychlops::Widgets::SelectBox stimulus_type2;\r
+ stimulus_type2.area.set(120, 20);\r
+ stimulus_type2.append(L"Continuous");\r
+ stimulus_type2.append(L"Periodic");\r
+ stimulus_type2.centering().shift(120.0,250.0);\r
+\r
+ Psychlops::Widgets::Slider duration_slider;\r
+ duration_slider.area.set(100,20);\r
+ duration_slider.centering().shift(120,280.0);\r
+ Interval rng = new Interval();\r
+ duration_slider.link(duration, 50<=rng<=950, 50.0, 50.0);\r
+ ///- user interface\r
+ ///- Preperation\r
+\r
+ ///+ Main loop\r
+ int frame = 0;\r
+ int period = refresh_int;\r
+ int movienum;\r
+ while(!Keyboard.esc.pushed()) {\r
+ Display.clear(new Color(bg_lum));\r
+ movienum = stimulus_type.getSelected(); //if "Type-I" is selected, 0, else frame refresh per sec\r
+\r
+ in;\r
+ else period = refresh_int;\r
+\r
+ if(frame>0){\r
+ movie[movienum, frame].centering().draw();\r
+ envelope.centering().draw();\r
+ component_movie[movienum*2, frame].centering().shift(-rect_size*0.5, -rect_size).draw();\r
+ envelope_small.centering().shift(-rect_size*0.5, -rect_size).draw();\r
+ component_movie[movienum*2+1, frame].centering().shift(rect_size*0.5, -rect_size).draw();\r
+ envelope_small.centering().shift(rect_size*0.5, -rect_size).draw();\r
+ }\r