• R/O
  • HTTP
  • SSH
  • HTTPS

cpp: Commit

psychlops cpp


Commit MetaInfo

Revisiondbc84b1bfa8135943b0de0c72ae454f8bafd29c2 (tree)
Time2016-07-10 16:41:36
AuthorHOSOKAWA Kenchi <hosokawa.kenchi@gmai...>
CommiterHOSOKAWA Kenchi

Log Message

cache

Change Summary

Incremental Difference

--- a/psychlops/core/graphic/psychlops_g_canvas.cpp
+++ b/psychlops/core/graphic/psychlops_g_canvas.cpp
@@ -117,7 +117,7 @@ namespace Psychlops {
117117 loadFontMinimum();
118118
119119 initAPIprop();
120-
120+
121121 if(!api->vsync_available_) {
122122 Rectangle *rect = new Rectangle(600, 20);
123123 rect->centering(getCenter().x, getHeight()-20);
@@ -334,8 +334,12 @@ namespace Psychlops {
334334
335335 //// Drawing Images
336336
337- Canvas& Canvas::image(const Image &img) {
338- drawImage(img, img.targetarea_.getLeft(), img.targetarea_.getTop());
337+ Canvas& Canvas::image(const Image &img) {
338+ if(img._zoom_percentage_ == 100) {
339+ drawImage(img, img.targetarea_.getLeft(), img.targetarea_.getTop());
340+ } else {
341+ drawImage((Image &)img, img.targetarea_);
342+ }
339343 return *this;
340344 }
341345 void Canvas::drawImage(const Image &img) {
--- a/psychlops/core/graphic/psychlops_g_image.cpp
+++ b/psychlops/core/graphic/psychlops_g_image.cpp
@@ -252,6 +252,11 @@ void Image::pix_ub_bits_mono_(int ix, int iy, double lum) {
252252 *(++p) = (unsigned char)0;
253253 }
254254 */
255+ Image& Image::_zoom_(const double percentage) {
256+ _zoom_percentage_ = percentage;
257+ targetarea_.resize(width_*(percentage/100.0), height_*(percentage/100.0));
258+ return *this;
259+ }
255260 Image& Image::alpha(const double a)
256261 {
257262 for(int y=0; y<getHeight(); y++)
--- a/psychlops/core/graphic/psychlops_g_image.h
+++ b/psychlops/core/graphic/psychlops_g_image.h
@@ -177,7 +177,8 @@ namespace IMAGE_FORMATS {
177177 }
178178
179179 public:
180- double _zoom_percentage_;
180+ double _zoom_percentage_;
181+ Image& _zoom_(const double percentage);
181182
182183 protected:
183184 int width_, height_;
--- a/psychlops/platform/gl/psychlops_g_cache.cpp
+++ b/psychlops/platform/gl/psychlops_g_cache.cpp
@@ -31,13 +31,16 @@ namespace Utilities {
3131 double mx = xx, my = yy;
3232 //double mx = drawee.getDatum().x, my = drawee.getDatum().y;
3333
34+ double w_ratio = 1.0;
35+ if(drawee._zoom_cache) { w_ratio = drawee.font.size/font_size; img._zoom_(100.0*w_ratio); }
36+
3437 double x, y;
3538 switch(anchor) {
3639 case Letters::TEXT_ALIGN_CENTER:
37- x = mx - img.getWidth() / 2;
40+ x = mx - img.getWidth() * w_ratio / 2;
3841 break;
3942 case Letters::TEXT_ALIGN_RIGHT:
40- x = mx - img.getWidth();
43+ x = mx - img.getWidth() * w_ratio;
4144 break;
4245 case Letters::NOT_SPECIFIED:
4346 case Letters::TEXT_ALIGN_LEFT:
Show on old repository browser