3 using namespace Psychlops;
6 class RectLuminance : public ExperimentalMethods::Demo {
9 // Widgets::SequentialScreenshot sc;
11 Psychlops::Rectangle rect;
17 display.set(Canvas::window);
18 gabor = new QuickGabor(10.0, 10.0, 1.0);
20 rect.set(100, 100).centering(0,0);
21 xr.set(100,100).shift(200,200);
22 xr.brush = Stroke(Color::red, 2, Stroke::SOLID);
26 arr.vec = Psychlops::Point(100,50);
29 Independent << bg_lum | "BG Luminance" | 0.0<=itv<=4095 | 128 | 1 , 1;
30 Independent << x | "X" | 0.0<=itv<=4095 | 128 | 1 , 1;
35 while(!Input::get(Keyboard::esc)) {
36 display.clear(Color(bg_lum/4095));
37 (*gabor).centering().draw();
42 arr.draw(Color::white);
43 if(Mouse::left.pressed()) display.var(Mouse::x, 100,100);
52 void psychlops_main() {
53 RectLuminance * exp = new RectLuminance;
62 #include <psychlops.h>
63 using namespace Psychlops;
66 const int DIVISION_MODES = 5;
67 const int MIN_DIVISION_MODES = 5;
68 const double SIGMA_MAGN = 6.0;
72 Canvas display(Canvas::window);
75 double size_whole= 400.0, wl = 30.0;
76 double contrast = 0.5, ori = 0.0, velocity = 15.0;
80 Independent << div | "Division" | 5<=rng<=9 | 1 | 1 ;
81 Independent << wl | "Wavelength" | 30.0<=rng<=60.0 | 5.0 | 1.0 ;
82 Independent << contrast | "Contrast" | 0<=rng<=1.0 | 0.1 | 0.01;
83 Independent << velocity | "Velocity" | -90.0<=rng<=90.0 | 15.0 | 1.0 ;
84 Independent << velmode | "Velocity Mode" | 0<=rng<=1 | 1 | 1 ;
85 Independent << ori | "Orientation" | -360.0<=rng<=720.0 | 30.0 | 15.0;
88 //Formatting and (re)locating Gabors
89 QuickGabor gabor[DIVISION_MODES][DIVISION_MODES+MIN_DIVISION_MODES][DIVISION_MODES+MIN_DIVISION_MODES];
90 for(int divs=0, divs_really=0; divs<DIVISION_MODES; divs++) {
91 divs_really = MIN_DIVISION_MODES+divs;
92 for(int x=0; x<DIVISION_MODES+MIN_DIVISION_MODES; x++) {
93 for(int y=0; y<DIVISION_MODES+MIN_DIVISION_MODES; y++) {
94 each_size = size_whole/divs_really;
95 gabor[divs][x][y].set((wl/(divs_really-y+1)), each_size/SIGMA_MAGN).centering().shift(each_size*((x+0.5)-(divs_really/2.0)), each_size*(divs_really/2.0-(y+0.5)));
96 gabor[divs][x][y].phase = Psychlops::random(360);
104 while(!Input::get(Keyboard::esc)) {
105 Display::clear(Color::gray);
106 divarr = div-MIN_DIVISION_MODES;
108 for(int x=0; x<div; x++) {
109 for(int y=0; y<div; y++) {
110 if(ori>360.0) ori -=360.0; if(ori<0.0) ori+=360.0;
112 //Set Gabor parameters
113 gabor[divarr][x][y].wavelength = wl / pow(4.0/3.0, y);
114 gabor[divarr][x][y].contrast = contrast;
115 gabor[divarr][x][y].orientation = ori;
117 gabor[divarr][x][y].phase += velocity * (1.0*x/div);
119 gabor[divarr][x][y].phase += velocity / gabor[divarr][x][y].wavelength * (1.0*x/div) * 20;
123 gabor[divarr][x][y].draw();
132 void psychlops_main()
135 p.setDesign(Procedure::DEMO);
136 p.setProcedure(&GaborChart);
142 #include <psychlops.h>
143 using namespace Psychlops; // Initially developed with Psychlops Win32 1.0.2 / 20080414
147 void RectLuminance() {
148 Canvas display(1024, 768, Canvas::window, Display::secondary);
152 double rect_size = 100;
153 double rect_lum = 0.5;
156 Psychlops::Rectangle rect(rect_size,rect_size);
160 Independent << rect_size | "Rect Size" | 1< rng< 500 | 10.0 | 2.0 ;
161 Independent << rect_lum | "Rect Luminance" | 0.0<=rng<=1.0 | 0.1 | 0.05;
162 Independent << bg_lum | "BG Luminance" | 0.0<=rng<=1.0 | 0.1 | 0.05;
163 Psychlops::Rectangle drawee(100,100);
166 while(!Input::get(Keyboard::esc)) {
167 Display::clear(bg_lum);
168 rect.resize(rect_size,rect_size).draw(rect_lum);
170 display.var((after-before).at_msec(), 100,100, Color::green);
171 if(Independent[&rect_lum].changed()) display.var((after-before).at_msec(), 100,200, Color::green);
172 drawee.centering().shift(Psychlops::random(100),0).draw(Color::black);
179 void psychlops_main() {
181 p.setDesign(Procedure::DEMO);
182 p.setProcedure(RectLuminance);