2 using namespace Psychlops; // Initially developed with Psychlops Win32 1.0.2 / 20080414
4 void drawGaussianFilter(Image &img, double sigma, double factor)
7 img.set(sigma*8, sigma*8, Image::RGBA);
8 const int width = img.getWidth(), height = img.getHeight();
10 for(int y=0; y<height; y++) {
12 for(int x=0; x<width; x++) {
14 r = sqrt(xp*xp+yp*yp);
15 r2 = -(r*r) / (2.0*sigma*sigma);
16 img.alpha(x,y,factor*(exp(r2)));
21 void psychlops_main() {
22 Canvas cnvs(1024,768,Canvas::window);
26 // Attach filter to Group
28 drawGaussianFilter( filter, 100, 1 );
29 filter.centering(0,0);
32 // Append 'filtered' Figures
33 Psychlops::Rectangle dot[100];
34 for(int i=0; i<100; i++) {
35 dot[i].fill = Color::white;
36 dot[i].set(5,5).centering(random(-300,300),random(-300,300)).join(gr);
40 gr.centering().draw();
43 while(!Keyboard::esc.pushed()) {}
48 const double E = 2.718281828459045;
49 const double LOG2E = 1.44269504088896340736;
50 double sigmoid(double x, double d, double a) { return 1 / ( 1 + pow(E, -(a*(x-d))) ); }
51 double log2NormalDistibution(double log_x, double octave_mu, double octave_sigma) { return Math::normalDistibution(log(log_x)*LOG2E, octave_mu, octave_sigma); }
52 double cumulativeLog2NormalDistibution(double log_x, double octave_mu, double octave_sigma) { return Math::cumulativeNormalDistibution(log(log_x)*LOG2E, octave_mu, octave_sigma); }
55 double bind(double x) {
56 return cumulativeLog2NormalDistibution(x, 2, 1.15/2);
58 double bind2(double x) {
59 return 1-cumulativeLog2NormalDistibution(x, 1, 1.15/2);
62 void psychlops_main() {
63 Canvas cnvs(1024,768,Canvas::window);
65 Figures::FunctionalPlot plot(256,256);
67 //plot.append(&bind2);
68 //plot.x_max=20; plot.x_min=0.0000001; plot.y_max=1.1; plot.y_min=-0.1;
70 plot.x_max=10; plot.x_min=-10; plot.y_max=1.1; plot.y_min=-1.1;
74 while(!Keyboard::esc.pushed()) {}
79 void psychlops_main() {
80 Canvas sampleA(Canvas::fullscreen);
83 img.clear(Color::blue);
84 img.rect(Psychlops::Rectangle(50,0,150,100),Color::green); // Draw rect to upper side
85 img.centering().draw();
88 Psychlops::Rectangle rect(500,500);
91 sampleA.to(target, rect.centering());
92 rect.draw(Color(1,0,0,0.2)); // show source area of Canvas::to
95 sampleA.flip(); // If Canvas::flip has been done bofore Canvas::to, Canvas::to won't work as you intended.
96 while(!Input::get(Keyboard::esc));
98 // writing outline of the image
99 target.line(0, 0, 0, target.getHeight(), Color::red);
100 target.line(0, 0, target.getWidth(), 0, Color::red);
101 target.line(0, 0, target.getWidth(), target.getHeight(), Color::red);
106 while(!Input::get(Keyboard::esc));
111 Psychlops::Rectangle rect1(1279,1023); Psychlops::Rectangle rect2;
112 Psychlops::Image Stimulus1(rect1); Psychlops::Image Stimulus2(rect1);
113 Psychlops::Color col(0.8);
115 void psychlops_main() {
116 Canvas sampleA(Canvas::fullscreen);
117 for(int y=0; y<10; y++) {
118 rect2.set(0, y*100+25, 1279, y*100+20+25);
119 Stimulus1.rect(rect2, col);
123 while(!Input::get(Keyboard::esc));
127 rect2.set(0,0,500,500);//x座標が指定できていない
128 //rect2.set(0,0,1680,500);//上下反転?
129 //rect2.set(0,500,1680,1000);//OK
131 sampleA.to(Stimulus2, rect2);
134 while(!Input::get(Keyboard::esc));