svg_loader: support stroke gradient

The loader was ready to handle the gradient stroke, but there was no API to support
it when the loader was introduced. We've had this API for a while already, so
its call has been added.
This commit is contained in:
Mira Grudzinska 2021-06-09 23:52:12 +02:00 committed by Hermet Park
parent 4acf89cf96
commit 9b1356e7cb
2 changed files with 14 additions and 6 deletions

View file

@ -2388,18 +2388,18 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
} }
static void _updateGradient(SvgNode* node, Array<SvgStyleGradient*>* gradidents) static void _updateGradient(SvgNode* node, Array<SvgStyleGradient*>* gradients)
{ {
if (node->child.count > 0) { if (node->child.count > 0) {
auto child = node->child.data; auto child = node->child.data;
for (uint32_t i = 0; i < node->child.count; ++i, ++child) { for (uint32_t i = 0; i < node->child.count; ++i, ++child) {
_updateGradient(*child, gradidents); _updateGradient(*child, gradients);
} }
} else { } else {
if (node->style->fill.paint.url) { if (node->style->fill.paint.url) {
node->style->fill.paint.gradient = _gradientDup(gradidents, node->style->fill.paint.url); node->style->fill.paint.gradient = _gradientDup(gradients, node->style->fill.paint.url);
} else if (node->style->stroke.paint.url) { } else if (node->style->stroke.paint.url) {
//node->style->stroke.paint.gradient = _gradientDup(gradList, node->style->stroke.paint.url); node->style->stroke.paint.gradient = _gradientDup(gradients, node->style->stroke.paint.url);
} }
} }
} }

View file

@ -232,7 +232,15 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v
if (style->stroke.paint.none) { if (style->stroke.paint.none) {
//Do nothing //Do nothing
} else if (style->stroke.paint.gradient) { } else if (style->stroke.paint.gradient) {
//TODO: Support gradient style if (!style->stroke.paint.gradient->userSpace) vg->bounds(&vx, &vy, &vw, &vh);
if (style->stroke.paint.gradient->type == SvgGradientType::Linear) {
auto linear = _applyLinearGradientProperty(style->stroke.paint.gradient, vg, vx, vy, vw, vh);
vg->stroke(move(linear));
} else if (style->stroke.paint.gradient->type == SvgGradientType::Radial) {
auto radial = _applyRadialGradientProperty(style->stroke.paint.gradient, vg, vx, vy, vw, vh);
vg->stroke(move(radial));
}
} else if (style->stroke.paint.url) { } else if (style->stroke.paint.url) {
//TODO: Apply the color pointed by url //TODO: Apply the color pointed by url
} else if (style->stroke.paint.curColor) { } else if (style->stroke.paint.curColor) {