Browse Source

Fix EllipseGeometry clone method

pull/11773/head
robloo 3 years ago
parent
commit
7548238388
  1. 41
      src/Avalonia.Base/Media/EllipseGeometry.cs

41
src/Avalonia.Base/Media/EllipseGeometry.cs

@ -56,6 +56,10 @@ namespace Avalonia.Media
/// <summary>
/// Gets or sets a rect that defines the bounds of the ellipse.
/// </summary>
/// <remarks>
/// When set, this takes priority over the other properties that define an
/// ellipse using a center point and X/Y-axis radii.
/// </remarks>
public Rect Rect
{
get => GetValue(RectProperty);
@ -65,6 +69,10 @@ namespace Avalonia.Media
/// <summary>
/// Gets or sets a double that defines the radius in the X-axis of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public double RadiusX
{
get => GetValue(RadiusXProperty);
@ -74,6 +82,10 @@ namespace Avalonia.Media
/// <summary>
/// Gets or sets a double that defines the radius in the Y-axis of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public double RadiusY
{
get => GetValue(RadiusYProperty);
@ -83,6 +95,10 @@ namespace Avalonia.Media
/// <summary>
/// Gets or sets a point that defines the center of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public Point Center
{
get => GetValue(CenterProperty);
@ -92,7 +108,30 @@ namespace Avalonia.Media
/// <inheritdoc/>
public override Geometry Clone()
{
return new EllipseGeometry(Rect);
// Note that the ellipse properties are used in two modes:
//
// 1. Rect-only Mode:
// Directly set the rectangle bounds the ellipse will fill
//
// 2. Center + Radii Mode:
// Set a center-point and then X/Y-axis radii that are used to
// calculate the rectangle bounds the ellipse will fill.
// This is the only mode supported by WPF.
//
// Rendering the ellipse will only ever use one of these two modes
// based on if the Rect property is set (not equal to default).
//
// This means it would normally be fine to copy ONLY the Rect property
// when it is set. However, while it would render the same, it isn't
// a true clone. We want to include all the properties here regardless
// of the rendering mode that will eventually be used.
return new EllipseGeometry()
{
Rect = Rect,
RadiusX = RadiusX,
RadiusY = RadiusY,
Center = Center,
};
}
/// <inheritdoc/>

Loading…
Cancel
Save