psychlops cpp
Revision | e84165b09393ea1992e0ec2696a044eb7c4e401d (tree) |
---|---|
Time | 2016-07-04 19:21:23 |
Author | HOSOKAWA Kenchi <hosokawa.kenchi@gmai...> |
Commiter | HOSOKAWA Kenchi |
font
@@ -78,23 +78,23 @@ namespace Psychlops { | ||
78 | 78 | Letters::Cache::Cache(APIFontProperties* id__, bool dirty__) : id(id__), dirty(dirty__) {} |
79 | 79 | |
80 | 80 | Letters::Letters() |
81 | - : str(), font(Font::default_font), width_(0), height_(0), vertical_align(BASELINE) | |
81 | + : str(), font(Font::default_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false) | |
82 | 82 | { |
83 | 83 | } |
84 | 84 | Letters::Letters(const char *init_str, const Font& init_font) |
85 | - : font(init_font), width_(0), height_(0), vertical_align(BASELINE) | |
85 | + : font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false) | |
86 | 86 | { |
87 | 87 | str = LocalEncodingtoWCHAR(init_str); |
88 | 88 | cache(); |
89 | 89 | } |
90 | 90 | Letters::Letters(const char *init_str, int size_, const Font& init_font) |
91 | - : font(init_font), width_(0), height_(0), vertical_align(BASELINE) | |
91 | + : font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false) | |
92 | 92 | { |
93 | 93 | str = LocalEncodingtoWCHAR(init_str, size_); |
94 | 94 | cache(); |
95 | 95 | } |
96 | 96 | Letters::Letters(const std::wstring &init_str, const Font& init_font) |
97 | - : str(init_str), font(init_font), width_(0), height_(0), vertical_align(BASELINE) | |
97 | + : str(init_str), font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false) | |
98 | 98 | { |
99 | 99 | cache(); |
100 | 100 | } |
@@ -85,9 +85,10 @@ namespace Psychlops { | ||
85 | 85 | typedef std::map<DrawableWithCache*, Cache> CacheID; |
86 | 86 | mutable CacheID caches; |
87 | 87 | // bool cached; |
88 | - double width_, height_; | |
88 | + double width_, height_; | |
89 | 89 | |
90 | 90 | public: |
91 | + bool _zoom_cache; | |
91 | 92 | Font font; |
92 | 93 | std::wstring str; |
93 | 94 | enum HorizontalAlign { NOT_SPECIFIED=-1, TEXT_ALIGN_LEFT=0, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT }; |
@@ -106,7 +106,8 @@ namespace Psychlops { | ||
106 | 106 | width_ = 0; |
107 | 107 | height_ = 0; |
108 | 108 | pixcomp_ = RGB; |
109 | - pixprec_ = BYTE; | |
109 | + pixprec_ = BYTE; | |
110 | + _zoom_percentage_ = 100; | |
110 | 111 | } |
111 | 112 | |
112 | 113 |
@@ -174,7 +174,10 @@ namespace IMAGE_FORMATS { | ||
174 | 174 | *(++bitmapf) = b/255.0; |
175 | 175 | if(pixcomp_==Image::RGB) return; else *(++bitmapf) = a; |
176 | 176 | } |
177 | - } | |
177 | + } | |
178 | + | |
179 | + public: | |
180 | + double _zoom_percentage_; | |
178 | 181 | |
179 | 182 | protected: |
180 | 183 | int width_, height_; |
@@ -61,8 +61,14 @@ namespace Utilities { | ||
61 | 61 | } |
62 | 62 | //img.draw(outer); |
63 | 63 | |
64 | + | |
64 | 65 | Color col(r,g,b,a); |
65 | - Rectangle targetarea(img.getLeft(), img.getTop(), img.getRight(), img.getBottom()); | |
66 | + Rectangle targetarea; | |
67 | + if(drawee._zoom_cache) { | |
68 | + targetarea.set(img.getLeft(), img.getTop(), img.getRight(), img.getBottom()); | |
69 | + } else { | |
70 | + targetarea.set(img.getLeft(), img.getTop(), img.getRight(), img.getBottom()); | |
71 | + } | |
66 | 72 | const Color zero_alpha(1,1,1,0,false); |
67 | 73 | glPushAttrib(GL_COLOR_BUFFER_BIT); |
68 | 74 | //img.move_to(posX, posY-cache_baseY); |
@@ -16,6 +16,7 @@ namespace Utilities { | ||
16 | 16 | { |
17 | 17 | public: |
18 | 18 | bool dirty_; |
19 | + double font_size; | |
19 | 20 | Image img; |
20 | 21 | CacheOnImage(); |
21 | 22 | ~CacheOnImage(); |
@@ -452,6 +452,7 @@ namespace Psychlops { | ||
452 | 452 | void APICanvasProperties::cacheText(Letters &drawee, Utilities::CacheOnImage& t) |
453 | 453 | { |
454 | 454 | int fontsize = (int)(drawee.font.size); |
455 | + t.font_size = drawee.font.size; | |
455 | 456 | int ix = 0, iy = 0; |
456 | 457 | //std:: str = wtext(drawee.text).dup; |
457 | 458 |
@@ -21,14 +21,14 @@ | ||
21 | 21 | </Compiler> |
22 | 22 | <Linker> |
23 | 23 | <Add option="-s" /> |
24 | - <Add library="..\dev\libpsychlopswin32gcc3.a" /> | |
25 | - <Add library="lib\libpng_mingw.a" /> | |
26 | - <Add library="lib\libfftw3.a" /> | |
24 | + <Add library="../dev/libpsychlopswin32gcc3.a" /> | |
25 | + <Add library="lib/libpng_mingw.a" /> | |
26 | + <Add library="lib/libfftw3.a" /> | |
27 | 27 | <Add library="opengl32" /> |
28 | 28 | <Add library="gdi32" /> |
29 | 29 | <Add library="comdlg32" /> |
30 | - <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" /> | |
31 | - <Add library="C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib" /> | |
30 | + <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" /> | |
31 | + <Add library="C:/Program Files/National Instruments/NI-DAQ/DAQmx ANSI C Dev/lib/msvc/NIDAQmx.lib" /> | |
32 | 32 | </Linker> |
33 | 33 | </Target> |
34 | 34 | <Target title="MinGW4"> |
@@ -46,33 +46,31 @@ | ||
46 | 46 | </Compiler> |
47 | 47 | <Linker> |
48 | 48 | <Add option="-s" /> |
49 | - <Add library="..\dev\libpsychlopswin32gcc4.a" /> | |
50 | - <Add library="lib\libpng_mingw.a" /> | |
51 | - <Add library="lib\libfftw3.a" /> | |
49 | + <Add library="../dev/libpsychlopswin32gcc4.a" /> | |
50 | + <Add library="lib/libpng_mingw.a" /> | |
51 | + <Add library="lib/libfftw3.a" /> | |
52 | 52 | <Add library="opengl32" /> |
53 | 53 | <Add library="gdi32" /> |
54 | 54 | <Add library="comdlg32" /> |
55 | - <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" /> | |
56 | - <Add library="C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib" /> | |
57 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_calib3d249.dll.a" /> | |
58 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_contrib249.dll.a" /> | |
59 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_core249.dll.a" /> | |
60 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_features2d249.dll.a" /> | |
61 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_flann249.dll.a" /> | |
62 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_gpu249.dll.a" /> | |
63 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_haartraining_engine.a" /> | |
64 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_highgui249.dll.a" /> | |
65 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_imgproc249.dll.a" /> | |
66 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_legacy249.dll.a" /> | |
67 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_ml249.dll.a" /> | |
68 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_nonfree249.dll.a" /> | |
69 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_objdetect249.dll.a" /> | |
70 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_ocl249.dll.a" /> | |
71 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_photo249.dll.a" /> | |
72 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_stitching249.dll.a" /> | |
73 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_superres249.dll.a" /> | |
74 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_video249.dll.a" /> | |
75 | - <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_videostab249.dll.a" /> | |
55 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_calib3d249.dll.a" /> | |
56 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_contrib249.dll.a" /> | |
57 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_core249.dll.a" /> | |
58 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_features2d249.dll.a" /> | |
59 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_flann249.dll.a" /> | |
60 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_gpu249.dll.a" /> | |
61 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_haartraining_engine.a" /> | |
62 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_highgui249.dll.a" /> | |
63 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_imgproc249.dll.a" /> | |
64 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_legacy249.dll.a" /> | |
65 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_ml249.dll.a" /> | |
66 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_nonfree249.dll.a" /> | |
67 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_objdetect249.dll.a" /> | |
68 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_ocl249.dll.a" /> | |
69 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_photo249.dll.a" /> | |
70 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_stitching249.dll.a" /> | |
71 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_superres249.dll.a" /> | |
72 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_video249.dll.a" /> | |
73 | + <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_videostab249.dll.a" /> | |
76 | 74 | </Linker> |
77 | 75 | </Target> |
78 | 76 | <Target title="BCC5.51"> |
@@ -91,8 +89,8 @@ | ||
91 | 89 | <Add option="-O1" /> |
92 | 90 | </Compiler> |
93 | 91 | <Linker> |
94 | - <Add library="..\dev\psychlopswin32bcc.lib" /> | |
95 | - <Add library="lib\libpng_bcc.lib" /> | |
92 | + <Add library="../dev/psychlopswin32bcc.lib" /> | |
93 | + <Add library="lib/libpng_bcc.lib" /> | |
96 | 94 | <Add library="import32.lib" /> |
97 | 95 | <Add library="cw32mt.lib" /> |
98 | 96 | <Add library="advapi32.lib" /> |
@@ -112,11 +110,11 @@ | ||
112 | 110 | <Add option="/Ox" /> |
113 | 111 | </Compiler> |
114 | 112 | <Linker> |
115 | - <Add library="..\dev\psychlopswin32vc9.lib" /> | |
116 | - <Add library="lib\libpng_vc9.lib" /> | |
117 | - <Add library="lib\glut32.lib" /> | |
118 | - <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" /> | |
119 | - <Add library="lib\libfftw3_vc9.lib" /> | |
113 | + <Add library="../dev/psychlopswin32vc9.lib" /> | |
114 | + <Add library="lib/libpng_vc9.lib" /> | |
115 | + <Add library="lib/glut32.lib" /> | |
116 | + <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" /> | |
117 | + <Add library="lib/libfftw3_vc9.lib" /> | |
120 | 118 | </Linker> |
121 | 119 | </Target> |
122 | 120 | <Target title="VC10"> |
@@ -132,13 +130,13 @@ | ||
132 | 130 | <Add option="/Ox" /> |
133 | 131 | </Compiler> |
134 | 132 | <Linker> |
135 | - <Add library="..\dev\psychlopswin32vc10.lib" /> | |
136 | - <Add library="lib\libpng_vc9.lib" /> | |
137 | - <Add library="lib\glut32.lib" /> | |
138 | - <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" /> | |
139 | - <Add library="lib\libfftw3_vc9.lib" /> | |
140 | - <Add library="C:\Library\frameworks\opencv\build\x86\vc10\lib\opencv_core249.lib" /> | |
141 | - <Add library="C:\Library\frameworks\opencv\build\x86\vc10\lib\opencv_highgui249.lib" /> | |
133 | + <Add library="../dev/psychlopswin32vc10.lib" /> | |
134 | + <Add library="lib/libpng_vc9.lib" /> | |
135 | + <Add library="lib/glut32.lib" /> | |
136 | + <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" /> | |
137 | + <Add library="lib/libfftw3_vc9.lib" /> | |
138 | + <Add library="C:/Library/frameworks/opencv/build/x86/vc10/lib/opencv_core249.lib" /> | |
139 | + <Add library="C:/Library/frameworks/opencv/build/x86/vc10/lib/opencv_highgui249.lib" /> | |
142 | 140 | </Linker> |
143 | 141 | </Target> |
144 | 142 | <Target title="VC12"> |
@@ -154,11 +152,11 @@ | ||
154 | 152 | <Add option="/Ox" /> |
155 | 153 | </Compiler> |
156 | 154 | <Linker> |
157 | - <Add library="..\dev\psychlopswin32vc12.lib" /> | |
158 | - <Add library="lib\libpng_vc9.lib" /> | |
159 | - <Add library="lib\glut32.lib" /> | |
160 | - <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" /> | |
161 | - <Add library="lib\libfftw3_vc9.lib" /> | |
155 | + <Add library="../dev/psychlopswin32vc12.lib" /> | |
156 | + <Add library="lib/libpng_vc9.lib" /> | |
157 | + <Add library="lib/glut32.lib" /> | |
158 | + <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" /> | |
159 | + <Add library="lib/libfftw3_vc9.lib" /> | |
162 | 160 | </Linker> |
163 | 161 | </Target> |
164 | 162 | </Build> |
@@ -192,15 +190,15 @@ | ||
192 | 190 | <Option compile="0" /> |
193 | 191 | <Option link="0" /> |
194 | 192 | </Unit> |
195 | - <Unit filename="fftfirm.cpp" /> | |
196 | - <Unit filename="inputTest.cpp"> | |
193 | + <Unit filename="fftfirm.cpp"> | |
197 | 194 | <Option compile="0" /> |
198 | 195 | <Option link="0" /> |
199 | 196 | </Unit> |
200 | - <Unit filename="main.cpp"> | |
197 | + <Unit filename="inputTest.cpp"> | |
201 | 198 | <Option compile="0" /> |
202 | 199 | <Option link="0" /> |
203 | 200 | </Unit> |
201 | + <Unit filename="main.cpp" /> | |
204 | 202 | <Unit filename="newfuncfirm.cpp"> |
205 | 203 | <Option compile="0" /> |
206 | 204 | <Option link="0" /> |
@@ -1,3 +1,33 @@ | ||
1 | +#include <psychlops.h> | |
2 | +using namespace Psychlops; | |
3 | + | |
4 | +void psychlops_main() { | |
5 | + Canvas cnvs(Canvas::window); | |
6 | + | |
7 | + Font font(L"MS P Gothic", 32); | |
8 | + Letters let(L"hoge", font); | |
9 | + let._zoom_cache = true; | |
10 | + | |
11 | + Clock after, before; | |
12 | + after.update(); | |
13 | + | |
14 | + while(!Keyboard::esc.pushed()) { | |
15 | + before = after; | |
16 | + after.update(); | |
17 | + | |
18 | + cnvs.clear(); | |
19 | + | |
20 | + font.size = random(100); | |
21 | + //let.setFont(font); | |
22 | + let.font = font; | |
23 | + let.centering().draw(Color::white); | |
24 | + | |
25 | + cnvs.var((after-before).at_msec(), 100,100, Color::green); | |
26 | + | |
27 | + cnvs.flip(); | |
28 | + } | |
29 | +} | |
30 | + | |
1 | 31 | /* |
2 | 32 | #include <psychlops.h> |
3 | 33 | using namespace Psychlops; |
@@ -138,7 +168,7 @@ void psychlops_main() | ||
138 | 168 | } |
139 | 169 | */ |
140 | 170 | |
141 | - | |
171 | +/* | |
142 | 172 | #include <psychlops.h> |
143 | 173 | using namespace Psychlops; // Initially developed with Psychlops Win32 1.0.2 / 20080414 |
144 | 174 |
@@ -183,4 +213,4 @@ void psychlops_main() { | ||
183 | 213 | p.run(); |
184 | 214 | |
185 | 215 | } |
186 | - | |
216 | +*/ |