mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
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
This commit is contained in:
parent
ae3141d65c
commit
3d80f0a9e9
4 changed files with 24 additions and 12 deletions
|
@ -42,6 +42,9 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
picture->size(&w, &h);
|
picture->size(&w, &h);
|
||||||
cout << "default tvg view size = " << w << " x " << h << endl;
|
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));
|
canvas->push(move(picture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,15 +108,20 @@ void exportTvg()
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
//nested paints
|
//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();
|
auto shape2 = tvg::Shape::gen();
|
||||||
shape2->appendRect(50, 0, 50, 100, 10, 40);
|
shape2->appendRect(50, 0, 50, 100, 10, 40);
|
||||||
shape2->fill(0, 0, 255, 125);
|
shape2->fill(0, 0, 255, 125);
|
||||||
scene1->push(move(shape2));
|
scene3->push(move(shape2));
|
||||||
scene1->rotate(10);
|
|
||||||
scene1->scale(2);
|
scene2->push(move(scene3));
|
||||||
scene1->translate(400,400);
|
|
||||||
|
|
||||||
auto shape3 = tvg::Shape::gen();
|
auto shape3 = tvg::Shape::gen();
|
||||||
shape3->appendRect(0, 0, 50, 100, 10, 40);
|
shape3->appendRect(0, 0, 50, 100, 10, 40);
|
||||||
|
@ -127,11 +132,7 @@ void exportTvg()
|
||||||
shape3->scale(2);
|
shape3->scale(2);
|
||||||
shape3->opacity(200);
|
shape3->opacity(200);
|
||||||
shape3->translate(400, 400);
|
shape3->translate(400, 400);
|
||||||
|
|
||||||
auto scene2 = tvg::Scene::gen();
|
|
||||||
scene2->push(move(scene1));
|
|
||||||
scene2->push(move(shape3));
|
scene2->push(move(shape3));
|
||||||
scene2->translate(100, 100);
|
|
||||||
|
|
||||||
if (scene->push(move(scene2)) != tvg::Result::Success) return;
|
if (scene->push(move(scene2)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ void exportTvg()
|
||||||
svg->opacity(200);
|
svg->opacity(200);
|
||||||
svg->scale(0.3);
|
svg->scale(0.3);
|
||||||
svg->translate(50, 450);
|
svg->translate(50, 450);
|
||||||
|
|
||||||
auto svgMask = tvg::Shape::gen();
|
auto svgMask = tvg::Shape::gen();
|
||||||
tvgDrawStar(svgMask.get());
|
tvgDrawStar(svgMask.get());
|
||||||
svgMask->fill(0, 0, 0, 255);
|
svgMask->fill(0, 0, 0, 255);
|
||||||
|
|
Binary file not shown.
|
@ -169,9 +169,16 @@ struct Picture::Impl
|
||||||
|
|
||||||
bool bounds(float* x, float* y, float* w, float* h) const
|
bool bounds(float* x, float* y, float* w, float* h) const
|
||||||
{
|
{
|
||||||
if (paint) return paint->pImpl->bounds(x, y, w, h);
|
if (x) *x = 0;
|
||||||
if (w) *w = this->w;
|
if (y) *y = 0;
|
||||||
if (h) *h = this->h;
|
if (w) {
|
||||||
|
if (loader) *w = loader->w;
|
||||||
|
else *w = 0;
|
||||||
|
}
|
||||||
|
if (h) {
|
||||||
|
if (loader) *h = loader->h;
|
||||||
|
else *h = 0;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue