From e718940f819c517ab33f5401a7a97b6ca0e79062 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Tue, 20 Feb 2024 01:02:09 +0100 Subject: [PATCH] sw_engine: fixing stroke outline In the case of non-uniform scaling for thick strokes, artifacts were visible. The calculations took into account the angle resulting from the already transformed points, whereas the untransformed points should have been considered - the transformation is taken into account in the next step. @issue: https://github.com/thorvg/thorvg/issues/1915 --- src/renderer/sw_engine/tvgSwStroke.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwStroke.cpp b/src/renderer/sw_engine/tvgSwStroke.cpp index eff63858..9ec4bd78 100644 --- a/src/renderer/sw_engine/tvgSwStroke.cpp +++ b/src/renderer/sw_engine/tvgSwStroke.cpp @@ -377,9 +377,6 @@ static void _lineTo(SwStroke& stroke, const SwPoint& to) //a zero-length lineto is a no-op; avoid creating a spurious corner if (delta.zero()) return; - //compute length of line - auto angle = mathAtan(delta); - /* The lineLength is used to determine the intersection of strokes outlines. The scale needs to be reverted since the stroke width has not been scaled. An alternative option is to scale the width of the stroke properly by @@ -387,6 +384,7 @@ static void _lineTo(SwStroke& stroke, const SwPoint& to) delta.x = static_cast(delta.x / stroke.sx); delta.y = static_cast(delta.y / stroke.sy); auto lineLength = mathLength(delta); + auto angle = mathAtan(delta); delta = {static_cast(stroke.width), 0}; mathRotate(delta, angle + SW_ANGLE_PI2);