diff --git a/src/examples/PictureTvg.cpp b/src/examples/PictureTvg.cpp index a7593cfa..7149e07c 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 1274460f..e2d30137 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 36f5a1d8..e68e57ab 100644 Binary files a/src/examples/images/test.tvg and b/src/examples/images/test.tvg differ diff --git a/src/lib/tvgPictureImpl.h b/src/lib/tvgPictureImpl.h index b5235a91..afa3acb2 100644 --- a/src/lib/tvgPictureImpl.h +++ b/src/lib/tvgPictureImpl.h @@ -169,9 +169,16 @@ struct Picture::Impl bool bounds(float* x, float* y, float* w, float* h) const { - if (paint) return paint->pImpl->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; }