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
This commit is contained in:
Mira Grudzinska 2024-02-20 01:02:09 +01:00 committed by Hermet Park
parent b150d71912
commit 6377257f8c

View file

@ -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<SwCoord>(delta.x / stroke.sx);
delta.y = static_cast<SwCoord>(delta.y / stroke.sy);
auto lineLength = mathLength(delta);
auto angle = mathAtan(delta);
delta = {static_cast<SwCoord>(stroke.width), 0};
mathRotate(delta, angle + SW_ANGLE_PI2);