From e16dcdcb6da919f3397b6d24034f9ba492a83222 Mon Sep 17 00:00:00 2001 From: Sergii Liebodkin Date: Tue, 16 Jul 2024 14:53:52 +0000 Subject: [PATCH] wg_engine: fix cubic generation artifacts (GradientStroke example) [GradientStroke](https://github.com/thorvg/thorvg/issues/2435) example More accurate coefitient computation --- src/renderer/wg_engine/tvgWgGeometry.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/renderer/wg_engine/tvgWgGeometry.cpp b/src/renderer/wg_engine/tvgWgGeometry.cpp index 1bd8a9e9..4fc18baa 100644 --- a/src/renderer/wg_engine/tvgWgGeometry.cpp +++ b/src/renderer/wg_engine/tvgWgGeometry.cpp @@ -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;