OSDN Git Service

first
[psychlops/cpp.git] / win32gl / test / main.cpp
1 /*
2 #include <psychlops.h>
3 using namespace Psychlops;
4
5
6 class RectLuminance : public ExperimentalMethods::Demo {
7         Canvas display;
8         double bg_lum, x;
9 //      Widgets::SequentialScreenshot sc;
10         Gabor *gabor;
11         Psychlops::Rectangle rect;
12         FigureGroupe g;
13         Figures::Cross xr;
14         Figures::Arrow arr;
15
16         void initialize() {
17                 display.set(Canvas::window);
18                 gabor = new QuickGabor(10.0, 10.0, 1.0);
19                 g.add(rect);
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);
23                 g.shift(100,0);
24                 g.rotation = -5;
25                 arr.centering();
26                 arr.vec = Psychlops::Point(100,50);
27
28                 Interval itv;
29                 Independent << bg_lum    | "BG Luminance"   | 0.0<=itv<=4095 |  128 | 1 , 1;
30                 Independent << x         | "X"              | 0.0<=itv<=4095 |  128 | 1 , 1;
31         }
32
33         void trial() {
34                 Letters let(L"hoge");
35                 while(!Input::get(Keyboard::esc)) {
36                         display.clear(Color(bg_lum/4095));
37                         (*gabor).centering().draw();
38                         let.centering();
39                         let.draw(Color::red);
40                         g.draw(Color::red);
41                         arr.vec.x -= 1;
42                         arr.draw(Color::white);
43                         if(Mouse::left.pressed()) display.var(Mouse::x, 100,100);
44
45                         display.flip();
46                 }
47         }
48
49 };
50
51
52 void psychlops_main() {
53         RectLuminance * exp = new RectLuminance;
54         exp->run();
55         delete exp;
56 }
57 */
58
59
60
61 /*
62 #include <psychlops.h>
63 using namespace Psychlops;
64
65
66 const int DIVISION_MODES = 5;
67 const int MIN_DIVISION_MODES = 5;
68 const double SIGMA_MAGN = 6.0;
69
70 void GaborChart() {
71
72         Canvas display(Canvas::window);
73         int div = 5, divarr;
74
75         double size_whole= 400.0, wl = 30.0;
76         double contrast = 0.5, ori = 0.0, velocity = 15.0;
77         int velmode = 1;
78
79         Range rng;
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;
86         double each_size;
87
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);
97                         }
98                 }
99         }
100
101         //Run Movie
102         display.showFPS();
103         display.watchFPS();
104         while(!Input::get(Keyboard::esc)) {
105                 Display::clear(Color::gray);
106                 divarr = div-MIN_DIVISION_MODES;
107
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;
111
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;
116                                 if(velmode) {
117                                         gabor[divarr][x][y].phase += velocity * (1.0*x/div);
118                                 } else {
119                                         gabor[divarr][x][y].phase += velocity / gabor[divarr][x][y].wavelength * (1.0*x/div) * 20;
120                                 }
121
122                                 //Drawing Gabors
123                                 gabor[divarr][x][y].draw();
124                         }
125                 }
126
127                 Display::flip();
128         }
129
130 }
131
132 void psychlops_main()
133 {
134         Procedure p;
135         p.setDesign(Procedure::DEMO);
136         p.setProcedure(&GaborChart);
137         p.run();
138 }
139 */
140
141
142 #include <psychlops.h>
143 using namespace Psychlops;      // Initially developed with Psychlops Win32 1.0.2 / 20080414
144
145
146
147 void RectLuminance() {
148         Canvas display(1024, 768, Canvas::window, Display::secondary);
149         display.showFPS();
150         display.watchFPS();
151
152         double rect_size = 100;
153         double rect_lum  = 0.5;
154         double bg_lum    = 0.2;
155
156         Psychlops::Rectangle rect(rect_size,rect_size);
157         rect.centering();
158
159         Range rng;
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);
164
165         Clock before, after;
166         while(!Input::get(Keyboard::esc)) {
167                 Display::clear(bg_lum);
168                 rect.resize(rect_size,rect_size).draw(rect_lum);
169                 after.update();
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);
173                 Display::flip();
174         }
175
176 }
177
178
179 void psychlops_main() {
180         Procedure p;
181         p.setDesign(Procedure::DEMO);
182         p.setProcedure(RectLuminance);
183         p.run();
184
185 }
186