From 55d9def9bc2e9ae3644b62ba3131cc783e4f1fde Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Tue, 16 Jun 2020 23:21:49 +0200 Subject: [PATCH] Add NearlyEquals for Size. --- src/Avalonia.Visuals/Size.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Size.cs b/src/Avalonia.Visuals/Size.cs index 0383094a5b..860270b346 100644 --- a/src/Avalonia.Visuals/Size.cs +++ b/src/Avalonia.Visuals/Size.cs @@ -189,7 +189,7 @@ namespace Avalonia } /// - /// Returns a boolean indicating whether the size is equal to the other given size. + /// Returns a boolean indicating whether the size is equal to the other given size (bitwise). /// /// The other size to test equality against. /// True if this size is equal to other; False otherwise. @@ -201,6 +201,16 @@ namespace Avalonia // ReSharper enable CompareOfFloatsByEqualityOperator } + /// + /// Returns a boolean indicating whether the size is equal to the other given size (numerically). + /// + /// The other size to test equality against. + /// True if this size is equal to other; False otherwise. + public bool NearlyEquals(Size other) + { + return MathUtilities.AreClose(_width, other._width) && MathUtilities.AreClose(_height, other._height); + } + /// /// Checks for equality between a size and an object. ///