mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
sw_engine fill: fix wrong gradient transformation
There transformation logic was not identical between shape & gradient gradient transform was applied into center of gradient world, while shape wasn't. So... we correct gradient transform metric to shape like. @Issues: 255
This commit is contained in:
parent
7147ebf21a
commit
d522c9d45e
1 changed files with 6 additions and 12 deletions
|
@ -106,18 +106,12 @@ bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix* tr
|
|||
if (linear->linear(&x1, &y1, &x2, &y2) != Result::Success) return false;
|
||||
|
||||
if (transform) {
|
||||
auto sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2));
|
||||
auto sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2));
|
||||
auto cx = (x2 - x1) * 0.5f + x1;
|
||||
auto cy = (y2 - y1) * 0.5f + y1;
|
||||
auto dx = x1 - cx;
|
||||
auto dy = y1 - cy;
|
||||
x1 = dx * transform->e11 + dy * transform->e12 + transform->e13 + (cx * sx);
|
||||
y1 = dx * transform->e21 + dy * transform->e22 + transform->e23 + (cy * sy);
|
||||
dx = x2 - cx;
|
||||
dy = y2 - cy;
|
||||
x2 = dx * transform->e11 + dy * transform->e12 + transform->e13 + (cx * sx);
|
||||
y2 = dx * transform->e21 + dy * transform->e22 + transform->e23 + (cy * sy);
|
||||
auto t1 = x1;
|
||||
x1 = t1 * transform->e11 + y1 * transform->e12 + transform->e13;
|
||||
y1 = t1 * transform->e21 + y1 * transform->e22 + transform->e23;
|
||||
auto t2 = x2;
|
||||
x2 = t2 * transform->e11 + y2 * transform->e12 + transform->e13;
|
||||
y2 = t2 * transform->e21 + y2 * transform->e22 + transform->e23;
|
||||
}
|
||||
|
||||
fill->linear.dx = x2 - x1;
|
||||
|
|
Loading…
Add table
Reference in a new issue