mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
svg_loader: limiting the ploted area of svg to viewBox
The 'viewBox' element given in the svg file determines the coordinates of the plotted area. ClipPath used in Svg loader.
This commit is contained in:
parent
0984241954
commit
2bb108b2f1
1 changed files with 8 additions and 1 deletions
|
@ -363,7 +363,14 @@ unique_ptr<Scene> _sceneBuildHelper(const SvgNode* node, float vx, float vy, flo
|
|||
scene->push(_sceneBuildHelper(*child, vx, vy, vw, vh));
|
||||
} else {
|
||||
auto shape = _shapeBuildHelper(*child, vx, vy, vw, vh);
|
||||
if (shape) scene->push(move(shape));
|
||||
// clipping the viewBox
|
||||
if (shape) {
|
||||
auto viewBoxClip = Shape::gen();
|
||||
viewBoxClip->appendRect(vx, vy, vw, vh, 0, 0);
|
||||
viewBoxClip->fill(0, 0, 0, 255);
|
||||
shape->composite(move(viewBoxClip), tvg::CompositeMethod::ClipPath);
|
||||
scene->push(move(shape));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Apply composite node
|
||||
|
|
Loading…
Add table
Reference in a new issue