-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
Description
Describe the bug
var drawing = new DrawingGroup();
using(var ctx = drawing.Open()) {
ctx.DrawRectangle(Brushes.Green, Pens.Red, new RoundedRect(new Rect(0, 0, 100, 50), 25));
}
results in
This is because DrawingGroup's context implementation simply creates a rectangle geometry without any radii in
Avalonia/src/Avalonia.Base/Media/DrawingGroup.cs
Lines 224 to 231 in 1bce702
| protected override void DrawRectangleCore(IBrush? brush, IPen? pen, RoundedRect rrect, BoxShadows boxShadows = default) | |
| { | |
| // Instantiate the geometry | |
| var geometry = _platformRenderInterface.CreateRectangleGeometry(rrect.Rect); | |
| // Add Drawing to the Drawing graph | |
| AddNewGeometryDrawing(brush, pen, new PlatformGeometry(geometry)); | |
| } |
As a workaround, DrawGeometry with a RectangleGeometry can be used.
To Reproduce
Create a DrawingGroup, call DrawingGroup.Open to obtain a DrawingContext and call DrawRectangle with a RoundedRect (or one of the other overloads that allows to specify corner radii).
Expected behavior
The specified corner radii should be honored.
Avalonia version
11.3.10
OS
Windows
Additional context
No response