OSDN Git Service

first
[psychlops/cpp.git] / osx / test / Shader / ShaderFieldPrec.cpp
1 #include <psychlops.h>
2 using namespace Psychlops;
3
4 void psychlops_main() {
5         Canvas cnvs(1024,1024,Canvas::window);
6         cnvs.watchFPS();
7         cnvs.showFPS();
8         Mouse::show();
9
10
11
12         Color::setGammaValue(1.0,1.0,1.0);
13
14
15         Image buf[10], reference[10], difference[10], difference2[10];
16
17         Figures::ShaderGrating grat;
18         grat.set(240,240);
19         grat.contrast = 1.0;
20         grat.wavelength = 30.0;
21         grat.phase = 0;
22         grat.orientation = PI/8;
23         grat.to(buf[0]);
24
25         Figures::ShaderExponentialDot dot;
26         dot.setSigma(30);
27         dot.factor = 1;
28         dot.to(buf[1]);
29
30         Figures::ShaderGabor gabor;
31         gabor.setSigma(30);
32         gabor.contrast = 1;
33         gabor.wavelength = 30.0;
34         gabor.phase = 0;
35         gabor.orientation = PI/8;
36         gabor.to(buf[2]);
37
38
39         Figures::drawGratingToImage(reference[0], 240,240 , 1.0/30.0, 1, PI/8, 0);
40         Figures::drawExponentialToImage(reference[1], 30, 1);
41         Figures::drawGaborToImage(reference[2], 30, 1.0/30.0, 1, PI/8, 0);
42
43
44         cnvs.clear(Color(0.25));
45         for(int i=0; i<3; i++) {
46                 Figures::substructImages(difference[i], buf[i], reference[i], 64.0);
47                 buf[i].shift(50,50+i*300).draw();
48                 reference[i].shift(350,50+i*300).draw();
49                 difference[i].shift(650, 50+i*300).draw();
50         }
51 /*
52         const int DIFF = 2, SLINE = 120;
53         difference2[DIFF].set(480,512);
54         int y1, y2;
55         for(int y=0; y<240; y++) {
56                 y1 = (int)(512-reference[DIFF].getPix(SLINE,y).getR()*512);
57                 y2 = (int)(512-buf[DIFF].getPix(SLINE,y).getR()*512);
58                 difference2[DIFF].rect(Psychlops::Rectangle(y*2, y1, y*2+1, 511), Color(0.4));
59                 if(y1>y2) difference2[DIFF].rect(Psychlops::Rectangle(y*2, y2, y*2+1, y1), Color::green);
60                 if(y1<y2) difference2[DIFF].rect(Psychlops::Rectangle(y*2, y1, y*2+1, y2), Color::red);
61         }
62         difference2[DIFF].centering().draw();
63 */
64
65         cnvs.flip();
66         while(!Keyboard::esc.pushed()) {
67         }
68 }
69