mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-16 21:15:02 +00:00
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:
parent
4acf89cf96
commit
9b1356e7cb
2 changed files with 14 additions and 6 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ static void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float v
|
||||||
if (style->fill.paint.none) {
|
if (style->fill.paint.none) {
|
||||||
//Do nothing
|
//Do nothing
|
||||||
} else if (style->fill.paint.gradient) {
|
} 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) {
|
if (style->fill.paint.gradient->type == SvgGradientType::Linear) {
|
||||||
auto linear = _applyLinearGradientProperty(style->fill.paint.gradient, vg, vx, vy, vw, vh);
|
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) {
|
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) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue