Skip to content

Fix GeometryBuilder.DrawRoundedCornersRectangle for Rect - #21482

Merged
grokys merged 9 commits into
AvaloniaUI:mainfrom
robloo:robloo/fix-DrawRoundedCornersRectangle
Aug 26, 2026
Merged

grokys merged 9 commits into
AvaloniaUI:mainfrom
robloo:robloo/fix-DrawRoundedCornersRectangle

Conversation

@robloo

@robloo robloo commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

What does the pull request do?

Fixes the issues discussed in:

What is the current behavior?

  1. RectangleGeometry (and Rectangle) drawing specifically with RadiusX or RadiusY has a small 1.57 degree rotation on each corner radius arc..
    • Rectangle drawing without any corner radius was never broken (is uses a fast path without a stream geometry context). This also explains why it was unnoticed for so long since RadiusX or RadiusY support came later in 11.x and probably still isn't widely used.
  2. ArcTo method comments have incorrect units and are not clearly worded.

What is the updated/expected behavior with this PR?

RectangleGeometry with corner radius drawing is fixed. ArcTo method comments are now more clearly worded.

How was the solution implemented (if it's not obvious)?

Obvious and now documented better.

Checklist

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #21445

@robloo

robloo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Leaving draft because more code review is required for related methods. The Arc shape has suspect code using radians. The PreciseArcTo() method is also suspect.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065949-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added bug backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 3, 2026
@MrJul MrJul added backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jul 9, 2026
@grokys

grokys commented Aug 24, 2026

Copy link
Copy Markdown
Member

Hey @robloo any news on this PR? Is it still a draft?

@grokys grokys self-assigned this Aug 24, 2026
@robloo

robloo commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@grokys It was still a draft because I suspected the issue was endemic to more APIs. The plan was to review them.

If the team wants to get this in I'll mark as ready. This PR does fix the actual issue ticket. Additional work can be done in follow-up PRs as time permits.

@robloo
robloo marked this pull request as ready for review August 24, 2026 18:46
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068728-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect corner-arc rotation when building rounded rectangles from a Rect + (radiusX, radiusY) by ensuring the emitted elliptical corner arcs are axis-aligned (rotation angle 0). Also clarifies IGeometryContext.ArcTo XML documentation to state rotationAngle is specified in degrees.

Changes:

  • Set rotationAngle: 0.0 for all four ArcTo calls in GeometryBuilder.DrawRoundedCornersRectangle(StreamGeometryContext, Rect, double, double) and remove the unused PiOver2 constant.
  • Update IGeometryContext.ArcTo XML docs to describe rotationAngle as degrees and improve parameter wording/punctuation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Avalonia.Base/Platform/IGeometryContext.cs Updates ArcTo XML documentation (degrees, clearer wording).
src/Avalonia.Base/Media/GeometryBuilder.cs Fixes rounded-rectangle corner arc rotation by using rotationAngle: 0.0.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@grokys grokys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@grokys
grokys enabled auto-merge August 26, 2026 08:46
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0068877-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@grokys
grokys added this pull request to the merge queue Aug 26, 2026
Merged via the queue into AvaloniaUI:main with commit 958066b Aug 26, 2026
10 checks passed
@robloo
robloo deleted the robloo/fix-DrawRoundedCornersRectangle branch August 26, 2026 17:15
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request Sep 2, 2026
…aUI#21482)

* Use 0 degree rotation angle in DrawRoundedCornersRectangle() for Rect

* Fix units in rotationAngle comment

* Improve ArcTo() XML docs

* Remove unused PiOver2 const causing build checks to fail

---------

Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeometryBuilder.DrawRoundedCornersRectangle passes corner-arc rotation in radians; only renders correctly because the Skia backend treats it as degrees

5 participants