From 0d18481fb3afa3d42efb066886cb4e2294878d53 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Fri, 9 Jun 2017 20:17:21 +0100 Subject: [PATCH] [SL.Core] add center property to rectangle --- src/SixLabors.Core/Primitives/Rectangle.cs | 10 ++++++++++ src/SixLabors.Core/Primitives/RectangleF.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/SixLabors.Core/Primitives/Rectangle.cs b/src/SixLabors.Core/Primitives/Rectangle.cs index 735920f0a..e7fa21867 100644 --- a/src/SixLabors.Core/Primitives/Rectangle.cs +++ b/src/SixLabors.Core/Primitives/Rectangle.cs @@ -110,6 +110,16 @@ namespace SixLabors.Primitives } } + /// + /// Gets the coordinates of the center of the rectangular region represented by this . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Point Center + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new Point(this.X + (this.Width / 2), this.Y + (this.Height / 2)); + } + /// /// Gets a value indicating whether this is empty. /// diff --git a/src/SixLabors.Core/Primitives/RectangleF.cs b/src/SixLabors.Core/Primitives/RectangleF.cs index 36578a455..f914091b3 100644 --- a/src/SixLabors.Core/Primitives/RectangleF.cs +++ b/src/SixLabors.Core/Primitives/RectangleF.cs @@ -110,6 +110,16 @@ namespace SixLabors.Primitives } } + /// + /// Gets the coordinates of the center of the rectangular region represented by this . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PointF Center + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new PointF(this.X + (this.Width / 2), this.Y + (this.Height / 2)); + } + /// /// Gets a value indicating whether this is empty. ///