2 using namespace Psychlops;
7 //// Psychlops runs at the first line of this function psychlops_main().
8 void psychlops_main() {
9 Canvas window(Canvas::window); //Create a window. Here, window variables are preset mode.
14 for(int i=0; i<100; i++) {
15 img[i].set(300,300,Image::RGBA);
16 img[i].shift(100,100);
17 img[i].clear(Color(1.0,0.7,0.5, 1.0));
20 img[0].line(0,0,0,79,Color::cyan);
21 img[0].line(0,79,79,79,Color::cyan);
22 img[0].line(79,79,79,0,Color::cyan);
23 img[0].line(79,0,0,0,Color::cyan);
27 std::cout << (after - before).at_msec() << " ms " << std::endl;
30 //// Set a figure size, position and color.
32 /*ID:FIGURE selector Rectangle Ellipse*/ figure; //Create a figure (Rectangle or Ellipse) variable.
33 figure.set( 100, 100 ); // Set the size of figure.
34 figure.fill = Psychlops::Color( 1, 1, 1 ); // Set the drawing color of figure in (R, G ,B) format.
35 figure.centering().shift( 0, 0 ); // Move the figure to the starting point.
39 int looming_direction=1, motion_dir=1; // Create variables for looming motion.
40 //looming_direction is a variable for size change.
41 //motion_dir is a variable for motion direction.
43 //// Draw each frames in a "while loop".
44 while(!Keyboard::esc.pushed()) { //exit a program when the escape key is pressed down.
45 window.clear(0); // Clear the window with a designated gray-scale level.
50 //// Calculate object's position and size for each frame.
52 if(frame% 30==0){ // a direction of size change will reverse at designated frames.
53 looming_direction=looming_direction*-1;
56 if(frame% 90==0){ // motion direction will reverse at designated frames.
63 //// Settting figure's properties
64 figure.resize(figure.getWidth()+looming_direction*1, // Scaling the figure in a direction given by "looming_direction".
65 figure.getHeight()+looming_direction*1);// Scaling the figure in a direction given by "looming_direction".
66 figure.shift(motion_dir*1, motion_dir*0);// Move the figure for 1 pixel in direction given by "motion_dir".
71 figure.draw(); // Drawing the figure with a designated color at designated position.
72 window.flip(); // Reflect the drawing for the display by flipping frame buffers.
76 ////make a step for next frames
88 Canvas cnvs(700, 700, Canvas::window);
90 int wid=200, hei=200, left=0, right=0;
93 Independent << typ | "typ";
94 Independent << wid | "wid" | 10 | 1;
95 Independent << hei | "hei" | 10 | 1;
96 Independent << left | "left" | 10 | 1;
97 Independent << right | "right" | 10 | 1;
99 //Image source("TocoToucan.png");
100 Image source("test.png"), ref("test.png");
102 Rectangle rect(100,100);
107 while(!Input::get(Keyboard::esc)) {
108 cnvs.clear(Color::gray);
110 source(rect.set(source.getWidth()-left, source.getHeight()-right)).centering(Drawable::prime->getCenter()).draw();
111 //ref.centering(Drawable::prime->getCenter()).draw();
113 source.centering(Drawable::prime->getCenter()).draw();
118 void psychlops_main() {
120 proc.setDesign(Procedure::DEMO);
121 proc.setProcedure(func);
127 double bellcurve(const double x, const double sigma) {
128 return exp( -(x*x) / (2.0*sigma*sigma) );
130 double bellcurve_(const double x) {
131 return bellcurve(x,5);
135 static double hoge = 0;
137 AppState::setThreadPriority(AppState::LOW);
139 hoge = analog->get();
143 class RectLuminance : public ExperimentalMethods::Demo {
151 Prototype::Thread recorder;
154 display.set(Canvas::window);
155 //AnalogOutput *analogout = new Devices::AnalogOutput_NIDAQmxBase();
158 //analog = new Devices::AnalogInput_NIDAQmxBase(1,1,0);
159 //recorder.create(&addToS);
162 Independent << tf | "Temporal Frequency" | -1.0<=itv<=3.0 | 1 | 0.5 , 1.0;
163 Independent << orientation | "Stimulus Orientation" | 0.0<=itv<=3 | 1 | 1 , 0,1,2,3;
164 Independent << numstim | "Stimulus Alignment" | 0.0<=itv<=2 | 1 | 1 , 0;
169 for(int x=-50; x<50; x++) for(int y=-50; y<50; y++) base.pix(x+50,y+50,col.set(x*x+y*y>50*50? 0.5 : (y+50)/100.0));
171 base.join(gp).centering(gp);
176 Rectangle mask(102,102);
177 Font font(L"Meirio", 10);
182 Figures::FunctionalPlot plot(300,300);
184 plot.append(&bellcurve_);
190 while(!Input::get(Keyboard::esc)) {
191 phase = Math::mod(phase+2*PI*pow(2,tf)/display.getRefreshRate(), 2*PI);
193 display.clear(Color::gray);
196 for(int x=-1; x<=1; x++ ) {
197 for(int y=-1; y<=1; y++ ) {
198 gp.rotation = orientation*90 +180*(cos(phase)<0 ? 1 : 0);
199 gp.centering().shift(x*102, y*102).draw();
201 mask.draw(col.set(.5,.5,.5,sin(phase)*(sin(phase)<0 ? -1 : 1)));
206 gp.rotation = orientation*90 +180*(cos(phase)<0 ? 1 : 0) + 180*(numstim==2 ? 1 : 0);
207 gp.centering().draw();
210 mask.draw(col.set(.5,.5,.5,sin(phase)*(sin(phase)<0 ? -1 : 1)));
211 if(Mouse::right.pressed()) display.var(Mouse::getWheelDelta().x, 300,300);
212 display.var(Mouse::getWheelDelta().y, 300,320);
214 let.draw(Color::white);
215 display.msg(L"fd", 500,500);
219 display.var(hoge, 400, 400);
226 void psychlops_main() {
227 RectLuminance * exp = new RectLuminance;
237 void psychlops_main() {
238 Canvas c(300,300,Canvas::window);
240 Rectangle a(100,100), b(100,100);
241 a.stroke = Stroke(Color::blue, 5, Stroke::DASHED);
242 b.shift(100,109).fill = Color::black;
244 cr.fill = Color::red;
245 Figures::Arrow arrow(0,0,100,50);
246 arrow.stroke = Stroke(Color::green, 5, Stroke::SOLID);
247 //arrow.fill = Color::green;
257 Rectangle clipper(200,200);
266 while(!Keyboard::esc.pushed()) {
267 c.clear(Color::gray);
271 let.draw(Color::red);
281 class RectLuminance : public ExperimentalMethods::Demo {
284 // Widgets::SequentialScreenshot sc;
292 display.set(640,400, Canvas::window);
293 gabor = new QuickGabor(10.0, 10.0, 1.0);
298 xr.set(100,100).shift(200,200);
299 xr.brush = Stroke(Color::red, 2, Stroke::SOLID);
302 g.axis = Psychlops::Point(1,1,1);
304 arr.vec = Psychlops::Point(100,50);
307 Independent << bg_lum | "BG Luminance" | 0.0<=itv<=4095 | 128 | 1 , 1;
308 Independent << x | "X" | 0.0<=itv<=4095 | 128 | 1 , 1;
316 let.color = Color::green;
317 while(!Input::get(Keyboard::esc)) {
318 display.clear(Color(bg_lum/4095));
319 (*gabor).centering().draw();
324 arr.draw(Color::white);
331 void psychlops_main() {
332 RectLuminance * exp = new RectLuminance;
340 void psychlops_main() {
344 Image pic2(pic.getWidth(), pic.getHeight());
345 pic.load("pic1.png");
347 display.clear(Color::white);
351 for(int x=0; x<pic.getWidth(); x++) {
352 display.progressbar(x, pic.getWidth());
353 for(int y=0; y<pic.getHeight(); y++) {
354 // col = pic.getPix(x,y);
355 // col2.set(1-col.getR(), 1-col.getG(), 1-col.getB());
356 // pic2.pix(x,y,col2);
363 Display::clear(Color::white);
365 while(!Input::get(Keyboard::esc)) {
378 class Test : public ExperimentalMethods::Demo {
385 d.set(Canvas::window);
388 Independent << r | 0<=rng<=1 | 1.0/255 | 16.0/255;
389 Independent << g | 0<=rng<=1 | 1.0/255 | 16.0/255;
390 Independent << l | 0<=rng<=1023 | 1 | 64;
391 Color::setGammaValue(6.75,1.0,1.0,Color::BITS_MONO);
396 Rectangle rect(100,100), rect1(100,100), rect2(100,100);
398 rect1.centering().shift(-100,0);
399 rect2.centering().shift(-50,-100);
400 Color col, ref1, ref2, bg;
401 while(!Input::get(Keyboard::esc)) {
406 ref1.set(127/255.0,0,0);
408 ref2.set(127/255.0,127/255.0,0);
416 void psychlops_main() {
417 Test *exp = new Test;