mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
svg_loader: fix bounds for gradient
In the case when bounds should not include a stroke width, width and height values were reduced by half of a stroke width, instead of the full width.
This commit is contained in:
parent
26f99372b0
commit
16a153c804
1 changed files with 10 additions and 10 deletions
|
@ -289,11 +289,11 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v
|
||||||
vg->bounds(&vx, &vy, &vw, &vh, false);
|
vg->bounds(&vx, &vy, &vw, &vh, false);
|
||||||
//According to: https://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBoxUnits (the last paragraph)
|
//According to: https://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBoxUnits (the last paragraph)
|
||||||
//a stroke width should be ignored for bounding box calculations
|
//a stroke width should be ignored for bounding box calculations
|
||||||
if (auto strokeHalfW = 0.5f * vg->strokeWidth()) {
|
if (auto strokeW = vg->strokeWidth()) {
|
||||||
vx += strokeHalfW;
|
vx += 0.5f * strokeW;
|
||||||
vy += strokeHalfW;
|
vy += 0.5f * strokeW;
|
||||||
vw -= strokeHalfW;
|
vw -= strokeW;
|
||||||
vh -= strokeHalfW;
|
vh -= strokeW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,11 +338,11 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v
|
||||||
//According to: https://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBoxUnits (the last paragraph)
|
//According to: https://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBoxUnits (the last paragraph)
|
||||||
//a stroke width should be ignored for bounding box calculations
|
//a stroke width should be ignored for bounding box calculations
|
||||||
vg->bounds(&vx, &vy, &vw, &vh, false);
|
vg->bounds(&vx, &vy, &vw, &vh, false);
|
||||||
if (auto strokeHalfW = 0.5f * vg->strokeWidth()) {
|
if (auto strokeW = vg->strokeWidth()) {
|
||||||
vx += strokeHalfW;
|
vx += 0.5f * strokeW;
|
||||||
vy += strokeHalfW;
|
vy += 0.5f * strokeW;
|
||||||
vw -= strokeHalfW;
|
vw -= strokeW;
|
||||||
vh -= strokeHalfW;
|
vh -= strokeW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue