mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-16 04:54:39 +00:00
sw_engine gradient: support x/y scale for radial gradient
Change-Id: Id725637e261642d0e92d100c73841278b7f44c1c
This commit is contained in:
parent
5fdc1f7fc8
commit
76a7c900be
2 changed files with 18 additions and 3 deletions
|
@ -193,6 +193,8 @@ struct SwFill
|
||||||
|
|
||||||
uint32_t* ctable;
|
uint32_t* ctable;
|
||||||
FillSpread spread;
|
FillSpread spread;
|
||||||
|
float sx, sy;
|
||||||
|
|
||||||
bool translucent;
|
bool translucent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -130,12 +130,25 @@ bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix* tr
|
||||||
if (radial->radial(&fill->radial.cx, &fill->radial.cy, &radius) != Result::Success) return false;
|
if (radial->radial(&fill->radial.cx, &fill->radial.cy, &radius) != Result::Success) return false;
|
||||||
if (radius < FLT_EPSILON) return true;
|
if (radius < FLT_EPSILON) return true;
|
||||||
|
|
||||||
|
fill->sx = 1.0f;
|
||||||
|
fill->sy = 1.0f;
|
||||||
|
|
||||||
if (transform) {
|
if (transform) {
|
||||||
auto tx = fill->radial.cx * transform->e11 + fill->radial.cy * transform->e12 + transform->e13;
|
auto tx = fill->radial.cx * transform->e11 + fill->radial.cy * transform->e12 + transform->e13;
|
||||||
auto ty = fill->radial.cx * transform->e21 + fill->radial.cy * transform->e22 + transform->e23;
|
auto ty = fill->radial.cx * transform->e21 + fill->radial.cy * transform->e22 + transform->e23;
|
||||||
fill->radial.cx = tx;
|
fill->radial.cx = tx;
|
||||||
fill->radial.cy = ty;
|
fill->radial.cy = ty;
|
||||||
radius *= transform->e33;
|
|
||||||
|
auto sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2));
|
||||||
|
auto sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2));
|
||||||
|
|
||||||
|
//FIXME; Scale + Rotation is not working properly
|
||||||
|
radius *= sx;
|
||||||
|
|
||||||
|
if (fabsf(sx - sy) > FLT_EPSILON) {
|
||||||
|
fill->sx = sx;
|
||||||
|
fill->sy = sy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fill->radial.a = radius * radius;
|
fill->radial.a = radius * radius;
|
||||||
|
@ -190,8 +203,8 @@ void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
|
||||||
if (fill->radial.a < FLT_EPSILON) return;
|
if (fill->radial.a < FLT_EPSILON) return;
|
||||||
|
|
||||||
//Rotation
|
//Rotation
|
||||||
auto rx = x + 0.5f - fill->radial.cx;
|
auto rx = (x + 0.5f - fill->radial.cx) * fill->sy;
|
||||||
auto ry = y + 0.5f - fill->radial.cy;
|
auto ry = (y + 0.5f - fill->radial.cy) * fill->sx;
|
||||||
auto inv2a = fill->radial.inv2a;
|
auto inv2a = fill->radial.inv2a;
|
||||||
auto rxy = rx * rx + ry * ry;
|
auto rxy = rx * rx + ry * ry;
|
||||||
auto rxryPlus = 2 * rx;
|
auto rxryPlus = 2 * rx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue