mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
svg_loader SceneBuilder: Remove incorrect calculation for linear gradient
Calculation of objectBoundingBox case in linear gradient is incorrect code. This causes the x,y coordinates of the linear gradient to be calculated incorrectly. So remove it.
This commit is contained in:
parent
50b2b1c7de
commit
bd566bdcb2
1 changed files with 0 additions and 29 deletions
|
@ -43,7 +43,6 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
|||
Fill::ColorStop* stops;
|
||||
int stopCount = 0;
|
||||
float fillOpacity = 255.0f;
|
||||
float gx, gy, gw, gh;
|
||||
|
||||
auto fillGrad = LinearGradient::gen();
|
||||
|
||||
|
@ -54,34 +53,6 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
|||
g->linear->y2 = g->linear->y2 * rh + ry;
|
||||
}
|
||||
|
||||
//In case of objectBoundingBox it need proper scaling
|
||||
if (!g->userSpace) {
|
||||
float scaleX = 1.0, scaleReversedX = 1.0;
|
||||
float scaleY = 1.0, scaleReversedY = 1.0;
|
||||
|
||||
//Check the smallest size, find the scale value
|
||||
if (rh > rw) {
|
||||
scaleY = ((float)rw) / rh;
|
||||
scaleReversedY = ((float)rh) / rw;
|
||||
} else {
|
||||
scaleX = ((float)rh) / rw;
|
||||
scaleReversedX = ((float)rw) / rh;
|
||||
}
|
||||
|
||||
vg->bounds(&gx, &gy, &gw, &gh);
|
||||
|
||||
float cy = ((float)gh) * 0.5 + gy;
|
||||
float cy_scaled = (((float)gh) * 0.5) * scaleReversedY;
|
||||
float cx = ((float)gw) * 0.5 + gx;
|
||||
float cx_scaled = (((float)gw) * 0.5) * scaleReversedX;
|
||||
|
||||
//= T(gx, gy) x S(scaleX, scaleY) x T(cx_scaled - cx, cy_scaled - cy) x (radial->x, radial->y)
|
||||
g->linear->x1 = g->linear->x1 * scaleX + scaleX * (cx_scaled - cx) + gx;
|
||||
g->linear->y1 = g->linear->y1 * scaleY + scaleY * (cy_scaled - cy) + gy;
|
||||
g->linear->x2 = g->linear->x2 * scaleX + scaleX * (cx_scaled - cx) + gx;
|
||||
g->linear->y2 = g->linear->y2 * scaleY + scaleY * (cy_scaled - cy) + gy;
|
||||
}
|
||||
|
||||
if (g->transform) {
|
||||
//Calc start point
|
||||
auto x = g->linear->x1;
|
||||
|
|
Loading…
Add table
Reference in a new issue