OSDN Git Service

123123
[psychlops/cpp.git] / win32gl / test / bugfix.cpp
1 #include <psychlops.h>
2 using namespace Psychlops;      // Initially developed with Psychlops Win32 1.0.2 / 20080414
3
4
5 void psychlops_main() {
6         //Canvas cnvs(1024,768,Canvas::window);
7         Canvas cnvs(Canvas::fullscreen);
8 \r
9         Letters let;\r
10         let.setString(L"test");\r
11         let.centering().draw(Color::white);\r
12 \r
13         int t= 0;\r
14
15         while(!Keyboard::esc.pushed()) {\r
16                 t++;\r
17                 cnvs.clear();\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
21                 cnvs.flip();\r
22         }
23 }
24 \r
25 \r
26 /*
27 void drawGaussianFilter(Image &img, double sigma, double factor)
28 {
29         img.release();
30         img.set(sigma*8, sigma*8, Image::RGBA);
31         const int width = img.getWidth(), height = img.getHeight();
32         double xp, yp, r, r2;
33         for(int y=0; y<height; y++) {
34                 yp = y-height/2.0;
35                 for(int x=0; x<width; x++) {
36                         xp = x-width/2.0;
37                         r = sqrt(xp*xp+yp*yp);
38                         r2 = -(r*r) / (2.0*sigma*sigma);
39                         img.alpha(x,y,factor*(exp(r2)));
40                 }
41         }
42 }
43
44 void psychlops_main() {
45         Canvas cnvs(1024,768,Canvas::window);
46
47         Group gr;
48
49         // Attach filter to Group
50         Image filter;
51         drawGaussianFilter( filter, 100, 1 );
52         filter.centering(0,0);
53         gr.clip(&filter);
54
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);
60         }
61
62         cnvs.clear();
63         gr.centering().draw();
64         cnvs.flip();
65
66         while(!Keyboard::esc.pushed()) {}
67
68 }
69 */
70 \r
71 /*
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); }
77
78
79 double bind(double x) {
80         return cumulativeLog2NormalDistibution(x, 2, 1.15/2);
81 }
82 double bind2(double x) {
83         return 1-cumulativeLog2NormalDistibution(x, 1, 1.15/2);
84 }
85
86 void psychlops_main() {
87         Canvas cnvs(1024,768,Canvas::window);
88
89         Figures::FunctionalPlot plot(256,256);
90         //plot.append(&bind);
91         //plot.append(&bind2);
92         //plot.x_max=20; plot.x_min=0.0000001; plot.y_max=1.1; plot.y_min=-0.1;
93         plot.append(&sin);
94         plot.x_max=10; plot.x_min=-10; plot.y_max=1.1; plot.y_min=-1.1;
95         plot.draw();
96         cnvs.flip();
97
98         while(!Keyboard::esc.pushed()) {}
99 }
100 */
101
102 /*
103 void psychlops_main() {
104         Canvas sampleA(Canvas::fullscreen);
105
106         Image img(200,200);
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();
110
111
112         Psychlops::Rectangle rect(500,500);
113         Image target;
114
115         sampleA.to(target, rect.centering());
116         rect.draw(Color(1,0,0,0.2));    // show source area of Canvas::to
117
118
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));
121
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);
126
127         sampleA.clear();
128         target.draw();
129         sampleA.flip();
130         while(!Input::get(Keyboard::esc));
131 }
132 */
133
134 /*
135 Psychlops::Rectangle rect1(1279,1023); Psychlops::Rectangle rect2;
136 Psychlops::Image Stimulus1(rect1); Psychlops::Image Stimulus2(rect1);
137 Psychlops::Color col(0.8);
138
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);
144         }
145         Stimulus1.draw();
146         sampleA.flip();
147         while(!Input::get(Keyboard::esc));
148
149         sampleA.flip();
150
151         rect2.set(0,0,500,500);//x座標が指定できていない
152         //rect2.set(0,0,1680,500);//上下反転?
153         //rect2.set(0,500,1680,1000);//OK
154
155         sampleA.to(Stimulus2, rect2);
156         Stimulus2.draw();
157         sampleA.flip();
158         while(!Input::get(Keyboard::esc));
159 }
160
161 */