From 0c602291cb0f486da6e49d46e171dd94bad609fe Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Mon, 19 Feb 2024 14:42:16 +0100 Subject: [PATCH] common: Changing the rounded rect starting point According to the SVG standard, drawing a rectangle starts at (x+rx, y) point. Till now it was (x+w, y+ry). The difference was visible only for dashed strokes. --- src/renderer/tvgShape.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 9d6be86e..b31529e1 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -215,20 +215,20 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) pImpl->lineTo(x + w, y + h); pImpl->lineTo(x, y + h); pImpl->close(); - //circle + //rounded rectangle or circle } else { auto hrx = rx * PATH_KAPPA; auto hry = ry * PATH_KAPPA; pImpl->grow(10, 17); - pImpl->moveTo(x + w, y + ry); + 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->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(); } @@ -400,4 +400,4 @@ Result Shape::fill(FillRule r) noexcept FillRule Shape::fillRule() const noexcept { return pImpl->rs.rule; -} \ No newline at end of file +}