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:
Mira Grudzinska 2021-03-07 16:02:04 +01:00 committed by Hermet Park
parent 0984241954
commit 2bb108b2f1

View file

@ -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