svg_loader: radial gradient transformation support

For now the gradient radius is scales like x-axis - it has to be changed
after issue #37 will be resolved.
This commit is contained in:
Mira Grudzinska 2021-06-18 00:53:49 +02:00 committed by JunsuChoi
parent b2020a9387
commit 8bb10fb261
2 changed files with 11 additions and 2 deletions

View file

@ -1870,6 +1870,8 @@ static bool _attrParseRadialGradientNode(void* data, const char* key, const char
grad->ref = _idFromHref(value);
} else if (!strcmp(key, "gradientUnits") && !strcmp(value, "userSpaceOnUse")) {
grad->userSpace = true;
} else if (!strcmp(key, "gradientTransform")) {
grad->transform = _parseTransformationMatrix(value);
} else {
return false;
}

View file

@ -114,8 +114,15 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
g->radial->fy = g->radial->fy * rh + ry;
}
//TODO: Radial gradient transformation is not yet supported.
//if (g->transform) {}
//TODO: Radial gradient transformation - all tests possible after rx/ry implementation
if (g->transform) {
auto cx = g->radial->cx * g->transform->e11 + g->radial->cy * g->transform->e12 + g->transform->e13;
g->radial->cy = g->radial->cx * g->transform->e21 + g->radial->cy * g->transform->e22 + g->transform->e23;
g->radial->cx = cx;
auto sx = sqrt(pow(g->transform->e11, 2) + pow(g->transform->e21, 2));
g->radial->r *= sx;
}
//TODO: Tvg is not support to focal
//if (g->radial->fx != 0 && g->radial->fy != 0) {