2 using namespace Psychlops; // Initially developed with Psychlops Win32 1.0.2 / 20080414
5 void psychlops_main() {
6 //Canvas cnvs(1024,768,Canvas::window);
7 Canvas cnvs(Canvas::fullscreen);
10 let.setString(L"test");
\r
11 let.centering().draw(Color::white);
\r
15 while(!Keyboard::esc.pushed()) {
\r
18 if(t%2==0) let.setString(L"test");
\r
19 else let.setString(L"日本語テスト");
\r
20 let.centering(Mouse::position).draw(Color::white);
\r
27 void drawGaussianFilter(Image &img, double sigma, double factor)
30 img.set(sigma*8, sigma*8, Image::RGBA);
31 const int width = img.getWidth(), height = img.getHeight();
33 for(int y=0; y<height; y++) {
35 for(int x=0; x<width; x++) {
37 r = sqrt(xp*xp+yp*yp);
38 r2 = -(r*r) / (2.0*sigma*sigma);
39 img.alpha(x,y,factor*(exp(r2)));
44 void psychlops_main() {
45 Canvas cnvs(1024,768,Canvas::window);
49 // Attach filter to Group
51 drawGaussianFilter( filter, 100, 1 );
52 filter.centering(0,0);
55 // Append 'filtered' Figures
56 Psychlops::Rectangle dot[100];
57 for(int i=0; i<100; i++) {
58 dot[i].fill = Color::white;
59 dot[i].set(5,5).centering(random(-300,300),random(-300,300)).join(gr);
63 gr.centering().draw();
66 while(!Keyboard::esc.pushed()) {}
72 const double E = 2.718281828459045;
73 const double LOG2E = 1.44269504088896340736;
74 double sigmoid(double x, double d, double a) { return 1 / ( 1 + pow(E, -(a*(x-d))) ); }
75 double log2NormalDistibution(double log_x, double octave_mu, double octave_sigma) { return Math::normalDistibution(log(log_x)*LOG2E, octave_mu, octave_sigma); }
76 double cumulativeLog2NormalDistibution(double log_x, double octave_mu, double octave_sigma) { return Math::cumulativeNormalDistibution(log(log_x)*LOG2E, octave_mu, octave_sigma); }
79 double bind(double x) {
80 return cumulativeLog2NormalDistibution(x, 2, 1.15/2);
82 double bind2(double x) {
83 return 1-cumulativeLog2NormalDistibution(x, 1, 1.15/2);
86 void psychlops_main() {
87 Canvas cnvs(1024,768,Canvas::window);
89 Figures::FunctionalPlot plot(256,256);
91 //plot.append(&bind2);
92 //plot.x_max=20; plot.x_min=0.0000001; plot.y_max=1.1; plot.y_min=-0.1;
94 plot.x_max=10; plot.x_min=-10; plot.y_max=1.1; plot.y_min=-1.1;
98 while(!Keyboard::esc.pushed()) {}
103 void psychlops_main() {
104 Canvas sampleA(Canvas::fullscreen);
107 img.clear(Color::blue);
108 img.rect(Psychlops::Rectangle(50,0,150,100),Color::green); // Draw rect to upper side
109 img.centering().draw();
112 Psychlops::Rectangle rect(500,500);
115 sampleA.to(target, rect.centering());
116 rect.draw(Color(1,0,0,0.2)); // show source area of Canvas::to
119 sampleA.flip(); // If Canvas::flip has been done bofore Canvas::to, Canvas::to won't work as you intended.
120 while(!Input::get(Keyboard::esc));
122 // writing outline of the image
123 target.line(0, 0, 0, target.getHeight(), Color::red);
124 target.line(0, 0, target.getWidth(), 0, Color::red);
125 target.line(0, 0, target.getWidth(), target.getHeight(), Color::red);
130 while(!Input::get(Keyboard::esc));
135 Psychlops::Rectangle rect1(1279,1023); Psychlops::Rectangle rect2;
136 Psychlops::Image Stimulus1(rect1); Psychlops::Image Stimulus2(rect1);
137 Psychlops::Color col(0.8);
139 void psychlops_main() {
140 Canvas sampleA(Canvas::fullscreen);
141 for(int y=0; y<10; y++) {
142 rect2.set(0, y*100+25, 1279, y*100+20+25);
143 Stimulus1.rect(rect2, col);
147 while(!Input::get(Keyboard::esc));
151 rect2.set(0,0,500,500);//x座標が指定できていない
152 //rect2.set(0,0,1680,500);//上下反転?
153 //rect2.set(0,500,1680,1000);//OK
155 sampleA.to(Stimulus2, rect2);
158 while(!Input::get(Keyboard::esc));