wg_engine: fix cubic generation artifacts (GradientStroke example)

[GradientStroke](https://github.com/thorvg/thorvg/issues/2435) example

More accurate coefitient computation
This commit is contained in:
Sergii Liebodkin 2024-07-16 14:53:52 +00:00 committed by Hermet Park
parent 8d150a17b4
commit e16dcdcb6d

View file

@ -93,9 +93,7 @@ void WgPolyline::appendCubic(WgPoint p1, WgPoint p2, WgPoint p3, size_t nsegs)
WgPoint p0 = pts.count > 0 ? pts.last() : WgPoint(0.0f, 0.0f);
nsegs = nsegs == 0 ? 1 : nsegs;
float dt = 1.0f / (float)nsegs;
float t = 0.0f;
for (size_t i = 1; i <= nsegs; i++) {
t += dt;
for (auto t = 0.0f; t <= 1.0f; t += dt) {
// get cubic spline interpolation coefficients
float t0 = 1.0f * (1.0f - t) * (1.0f - t) * (1.0f - t);
float t1 = 3.0f * (1.0f - t) * (1.0f - t) * t;