OSDN Git Service

1.7.0
[psychlops/cpp.git] / win32gl / test / compilenew.cpp
1 \r
2 // Motion with glass patterns.\r
3 // Ross, J., Badcock, D. R., and Hayes, A. (2000)\r
4 // Coherent global motion in the absence of coherent velocity signals.\r
5 // Current Biology, 10, 679-682.\r
6 ///+ Prefix\r
7 //// Include Psychlops Package\r
8 #include <psychlops.h>\r
9 using namespace Psychlops;    // Initially developed with Psychlops Win32 1.5.3 / 20110311\r
10 ///- Prefix\r
11 \r
12 ///+ Stimulus drawing function\r
13 //// A function for stimulus drawing (main body)\r
14 \r
15 \r
16 void psychlops_main() {\r
17         Canvas cnvs(Canvas::window);\r
18 \r
19         Letters let(L"flower_png24.png");\r
20         let.fill = Color::white;\r
21 \r
22         Psychlops::Ellipse rect(100,100);\r
23         rect.fill = Color::red;\r
24 \r
25         Devices::GenericParallelPort trigger("USB_PARALLEL", 1+8);\r
26 \r
27         int t=0;\r
28 \r
29         while(!Keyboard::esc.pushed()) {\r
30                 t++;\r
31                 Display::clear(); //Clear window\r
32 \r
33                 //if(t%100 == 0)\r
34                 //      rs = CreateProcess("C:\\Windows\\System32\\print.exe",(LPTSTR)" /D:LPT1 D:\\Users\\hskwk\\Desktop\\zzz.txt",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);\r
35 \r
36                 if(t%120==0) trigger.trigger();\r
37 \r
38                 Display::flip(); // Flip frame buffers\r
39         }\r
40 }\r
41 ///- Stimulus drawing function\r
42 \r
43 \r
44 \r
45 #if 0\r
46 \r
47 // Motion with glass patterns.\r
48 // Ross, J., Badcock, D. R., and Hayes, A. (2000)\r
49 // Coherent global motion in the absence of coherent velocity signals.\r
50 // Current Biology, 10, 679-682.\r
51 ///+ Prefix\r
52 //// Include Psychlops Package\r
53 #include <psychlops.h>\r
54 using namespace Psychlops;    // Initially developed with Psychlops Win32 1.5.3 / 20110311\r
55 ///- Prefix\r
56 \r
57 ///+ Stimulus drawing function\r
58 //// A function for stimulus drawing (main body)\r
59 void psychlops_main() {\r
60 \r
61         Canvas cnvs(Canvas::window);\r
62 \r
63         Letters let(L"flower_png24.png");\r
64         let.fill = Color::white;\r
65 \r
66         Psychlops::Ellipse rect(100,100);\r
67         rect.fill = Color::red;\r
68 \r
69         while(!Keyboard::esc.pushed()) {\r
70                 Display::clear(); //Clear window\r
71 \r
72                 rect.centering();\r
73                 std::cout << rect.getDatum().x << std::endl;\r
74                 rect.shift(100,100).draw();\r
75                 std::cout << rect.getDatum().x << std::endl << std::endl;\r
76                 let.centering();\r
77                 let.shift(100,100).draw();\r
78                 std::cout << let.getDatum().x << std::endl;\r
79 \r
80                 Display::flip(); // Flip frame buffers\r
81         }\r
82 \r
83         //Figures::Movie mov;\r
84         //mov.bin_path = "C:\\";\r
85 }\r
86 ///- Stimulus drawing function\r
87 \r
88 \r
89 \r
90 #include <psychlops.h>\r
91 using namespace Psychlops;\r
92 \r
93 \r
94 Clock before, after;\r
95 void memoBefore() { before.update(); }\r
96 double pastTime() { after.update(); return (after-before).at_msec(); }\r
97 \r
98 \r
99 void psychlops_main() {\r
100 \r
101 \r
102         Display target_display = Display::secondary;\r
103         std::cout << target_display.width << std::endl;\r
104         std::cout << Display::secondary.getHeight() << std::endl;\r
105 \r
106 \r
107         Canvas display(1024, 768, Canvas::window, target_display);\r
108         Range rng;\r
109 /*\r
110         Mouse::show();\r
111         Color::setGammaValue(1.0,1.0,1.0);\r
112 \r
113         double cutoff1=1.0,cutoff2=0.0;\r
114         Widgets::Slider slider[3];\r
115         slider[0].link(cutoff1, "cutoff1"  , 0<=rng<=256, 1);\r
116         slider[1].link(cutoff2, "half width"  , 0<=rng<=1, 0.125);\r
117 */\r
118 \r
119 /*\r
120         //void drawGrating(Image &img, int width, int height, double wavelength, double contrast, double orientation, double phase);
121         //void drawGaussian(Image &img, double sigma, double factor);
122         //void drawGabor(Image &img, double sigma, double wavelength, double contrast, double orientation, double phase);\r
123         std::stringstream ss;
124         Image img;\r
125         for(double wavelength_=2; wavelength_<8; wavelength_+=1.0 )\r
126         {\r
127                 for(double ori = 0; ori<180.0; ori+=30)\r
128                 {\r
129                         for(double amp = 0.25; amp<=1; amp+=0.25)\r
130                         {\r
131                                 for(double phase = 0; phase<360.0; phase+=30)\r
132                                 {\r
133                                         Figures::drawGrating(img, 36, 36, pow(2,wavelength_), amp, ori/360*2*PI, phase/360*2*PI);\r
134                                         ss.str("");\r
135                                         ss << "output/Grating_wav" << pow(2,wavelength_) << "_amp" << amp << "_ori" << ori << "_pha" << phase << ".png";\r
136                                         img.save(ss.str());\r
137                                         //Figures::drawGrating(img, 45, 45, pow(2,wavelength_), amp, ori/360*2*PI, phase/360*2*PI);\r
138                                 }\r
139                         }\r
140                 }\r
141         }\r
142 */\r
143 \r
144 /*\r
145         while(!Keyboard::esc.pushed()) {\r
146 \r
147                 memoBefore();\r
148                 std::cout << pastTime() << std::endl;\r
149 \r
150 \r
151                 memoBefore();\r
152 */\r
153 \r
154         Figures::Movie m;\r
155         m.source.set(100,100).centering();\r
156 \r
157                 //while(!Keyboard::esc.pushed()) {\r
158                 for(int j=0; j<10; j++) {\r
159                         display.clear(Color::blue);\r
160 \r
161 \r
162                         //img.centering().draw();\r
163                         for(int i=0; i<2; i++)\r
164                         {\r
165                                 //slider[i].setDatum(Point(0,0)).shift(20, i*25 + 10).draw();\r
166                         }\r
167                         m.capture();\r
168                         //display.to(m[j], r);\r
169                         display.flip();\r
170                 }\r
171                 m.save("test.gif");\r
172         //      std::cout << pastTime() << std::endl;\r
173         //}* /\r
174 }\r
175 #endif\r