From adf92beef55794fdf40e29b3b822c7bba8bddf0b Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 24 Jan 2024 10:57:25 +0900 Subject: [PATCH] renderer/shape: rectified the round rectangle start position. adjusted the starting position of the rounded rectangle to 90 degrees to ensure compatibility with the Lottie trim path effect. This modification follows the earlier circle correction applied to the rectangle. issue: https://github.com/thorvg/thorvg/issues/1933 --- src/renderer/tvgShape.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 7a3297a9..ed9f3786 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -216,31 +216,19 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) pImpl->lineTo(x, y + h); pImpl->close(); //circle - } else if (mathEqual(rx, halfW) && mathEqual(ry, halfH)) { - auto rxKappa = rx * PATH_KAPPA; - auto ryKappa = ry * PATH_KAPPA; - auto cx = x + (w * 0.5f); - auto cy = y + (h * 0.5f); - pImpl->grow(6, 13); - pImpl->moveTo(cx + rx, cy); - pImpl->cubicTo(cx + rx, cy + ryKappa, cx + rxKappa, cy + ry, cx, cy + ry); - pImpl->cubicTo(cx - rxKappa, cy + ry, cx - rx, cy + ryKappa, cx - rx, cy); - pImpl->cubicTo(cx - rx, cy - ryKappa, cx - rxKappa, cy - ry, cx, cy - ry); - pImpl->cubicTo(cx + rxKappa, cy - ry, cx + rx, cy - ryKappa, cx + rx, cy); - pImpl->close(); } else { auto hrx = rx * PATH_KAPPA; auto hry = ry * PATH_KAPPA; pImpl->grow(10, 17); - pImpl->moveTo(x + rx, y); - pImpl->lineTo(x + w - rx, y); - pImpl->cubicTo(x + w - rx + hrx, y, x + w, y + ry - hry, x + w, y + ry); + pImpl->moveTo(x + w, y + ry); pImpl->lineTo(x + w, y + h - ry); pImpl->cubicTo(x + w, y + h - ry + hry, x + w - rx + hrx, y + h, x + w - rx, y + h); pImpl->lineTo(x + rx, y + h); pImpl->cubicTo(x + rx - hrx, y + h, x, y + h - ry + hry, x, y + h - ry); pImpl->lineTo(x, y + ry); pImpl->cubicTo(x, y + ry - hry, x + rx - hrx, y, x + rx, y); + pImpl->lineTo(x + w - rx, y); + pImpl->cubicTo(x + w - rx + hrx, y, x + w, y + ry - hry, x + w, y + ry); pImpl->close(); }