From 73895932355593f3655b8811f513d02e0a9d120d Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 12 Jan 2024 18:37:30 +0900 Subject: [PATCH] renderer/shape: fixed a regression bug the bug was introduced in 9bf8bb018d9e17f64af09a55ee39a1d1a2dc9a2e. Migrated the circle commands to the rectangle, which is currently necessary. Retained the previous circle commands for backward compatibility. --- src/renderer/tvgShape.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index b56938e1..37df654e 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -130,11 +130,11 @@ Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept auto ryKappa = ry * PATH_KAPPA; pImpl->grow(6, 13); - pImpl->moveTo(cx + rx, cy); + pImpl->moveTo(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->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(); return Result::Success; @@ -217,7 +217,17 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) pImpl->close(); //circle } else if (mathEqual(rx, halfW) && mathEqual(ry, halfH)) { - return appendCircle(x + (w * 0.5f), y + (h * 0.5f), rx, ry); + 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;