diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index ccb52420..8a730082 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -2388,18 +2388,18 @@ static SvgStyleGradient* _gradientDup(Array* gradients, const } -static void _updateGradient(SvgNode* node, Array* gradidents) +static void _updateGradient(SvgNode* node, Array* gradients) { if (node->child.count > 0) { auto child = node->child.data; for (uint32_t i = 0; i < node->child.count; ++i, ++child) { - _updateGradient(*child, gradidents); + _updateGradient(*child, gradients); } } else { 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) { - //node->style->stroke.paint.gradient = _gradientDup(gradList, node->style->stroke.paint.url); + node->style->stroke.paint.gradient = _gradientDup(gradients, node->style->stroke.paint.url); } } } diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 1459811a..445c6671 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -195,7 +195,7 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v if (style->fill.paint.none) { //Do nothing } else if (style->fill.paint.gradient) { - if (!style->fill.paint.gradient->userSpace) vg->bounds(&vx, &vy, &vw, &vh); + if (!style->fill.paint.gradient->userSpace) vg->bounds(&vx, &vy, &vw, &vh); if (style->fill.paint.gradient->type == SvgGradientType::Linear) { auto linear = _applyLinearGradientProperty(style->fill.paint.gradient, vg, vx, vy, vw, vh); @@ -232,7 +232,15 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v if (style->stroke.paint.none) { //Do nothing } 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) { //TODO: Apply the color pointed by url } else if (style->stroke.paint.curColor) {