From 9da2a68d3380995ca38eb5ab64e446a94d148eed Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 25 Aug 2021 15:17:25 +0900 Subject: [PATCH] common picture: quick fix the broken bounds() interface. picture must return the boundary info - 0, 0, w, h We assume that it has a designated picture size. Aside from this issue, bounds() api must be reviewed, its behavior is quite in a trouble... unless the result is not transformed, its information is useless... @Issue: https://github.com/Samsung/thorvg/issues/741 --- src/examples/PictureTvg.cpp | 3 +++ src/examples/TvgSaver.cpp | 20 +++++++++++--------- src/examples/images/test.tvg | Bin 243411 -> 243411 bytes src/lib/tvgPictureImpl.h | 13 ++++++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/examples/PictureTvg.cpp b/src/examples/PictureTvg.cpp index a7593cf..7149e07 100644 --- a/src/examples/PictureTvg.cpp +++ b/src/examples/PictureTvg.cpp @@ -42,6 +42,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) picture->size(&w, &h); cout << "default tvg view size = " << w << " x " << h << endl; + picture->translate(w * 0.1f, h * 0.1f); + picture->size(w * 0.8f, h * 0.8f); + canvas->push(move(picture)); } diff --git a/src/examples/TvgSaver.cpp b/src/examples/TvgSaver.cpp index 1274460..e2d3013 100644 --- a/src/examples/TvgSaver.cpp +++ b/src/examples/TvgSaver.cpp @@ -108,15 +108,20 @@ void exportTvg() free(data); //nested paints - auto scene1 = tvg::Scene::gen(); + auto scene2 = tvg::Scene::gen(); + scene2->translate(100, 100); + + auto scene3 = tvg::Scene::gen(); + scene3->rotate(10); + scene3->scale(2); + scene3->translate(400,400); auto shape2 = tvg::Shape::gen(); shape2->appendRect(50, 0, 50, 100, 10, 40); shape2->fill(0, 0, 255, 125); - scene1->push(move(shape2)); - scene1->rotate(10); - scene1->scale(2); - scene1->translate(400,400); + scene3->push(move(shape2)); + + scene2->push(move(scene3)); auto shape3 = tvg::Shape::gen(); shape3->appendRect(0, 0, 50, 100, 10, 40); @@ -127,11 +132,7 @@ void exportTvg() shape3->scale(2); shape3->opacity(200); shape3->translate(400, 400); - - auto scene2 = tvg::Scene::gen(); - scene2->push(move(scene1)); scene2->push(move(shape3)); - scene2->translate(100, 100); if (scene->push(move(scene2)) != tvg::Result::Success) return; @@ -141,6 +142,7 @@ void exportTvg() svg->opacity(200); svg->scale(0.3); svg->translate(50, 450); + auto svgMask = tvg::Shape::gen(); tvgDrawStar(svgMask.get()); svgMask->fill(0, 0, 0, 255); diff --git a/src/examples/images/test.tvg b/src/examples/images/test.tvg index 36f5a1d840831a0ac98c9282fb8f55aecccad0d6..e68e57abb0203649dbd1f132f705f6c9c2463b66 100644 GIT binary patch delta 40 tcmccomhbXgK9P`&{Gu>-0|NsS0|N$zL>CZl6loP-0|NsS1B3tn>+3pImpl->bounds(x, y, w, h); - if (w) *w = this->w; - if (h) *h = this->h; + if (x) *x = 0; + if (y) *y = 0; + if (w) { + if (loader) *w = loader->w; + else *w = 0; + } + if (h) { + if (loader) *h = loader->h; + else *h = 0; + } return true; } -- 2.7.4