From f429e9f723cb9372e61fca9d14522a70b1c0fa60 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 5 May 2015 12:38:21 +0200 Subject: [PATCH] Fixed Rectangle snapping. --- Perspex.Controls/Border.cs | 2 +- Perspex.Controls/Shapes/Ellipse.cs | 3 +-- Perspex.Controls/Shapes/Rectangle.cs | 3 ++- Perspex.SceneGraph/Rect.cs | 2 +- .../Rectangle/Rectangle_1px_Stroke.expected.png | Bin 628 -> 609 bytes 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Perspex.Controls/Border.cs b/Perspex.Controls/Border.cs index 133e2c63eb..b22a22c37f 100644 --- a/Perspex.Controls/Border.cs +++ b/Perspex.Controls/Border.cs @@ -51,7 +51,7 @@ namespace Perspex.Controls Brush background = this.Background; Brush borderBrush = this.BorderBrush; double borderThickness = this.BorderThickness; - Rect rect = new Rect(this.Bounds.Size).Deflate(this.BorderThickness / 2); + Rect rect = new Rect(this.Bounds.Size).Deflate(this.BorderThickness); if (background != null) { diff --git a/Perspex.Controls/Shapes/Ellipse.cs b/Perspex.Controls/Shapes/Ellipse.cs index bec10c30ea..740f5b0561 100644 --- a/Perspex.Controls/Shapes/Ellipse.cs +++ b/Perspex.Controls/Shapes/Ellipse.cs @@ -20,8 +20,7 @@ namespace Perspex.Controls.Shapes { if (this.geometry == null || this.geometrySize != this.Bounds.Size) { - var rect = new Rect(0, 0, this.Bounds.Size.Width, this.Bounds.Size.Height); - rect = rect.Deflate(this.StrokeThickness / 2); + var rect = new Rect(this.Bounds.Size).Deflate(this.StrokeThickness); this.geometry = new EllipseGeometry(rect); this.geometrySize = this.Bounds.Size; } diff --git a/Perspex.Controls/Shapes/Rectangle.cs b/Perspex.Controls/Shapes/Rectangle.cs index 8bdc2589e8..4e34ba2d8b 100644 --- a/Perspex.Controls/Shapes/Rectangle.cs +++ b/Perspex.Controls/Shapes/Rectangle.cs @@ -20,7 +20,8 @@ namespace Perspex.Controls.Shapes { if (this.geometry == null || this.geometrySize != this.Bounds.Size) { - this.geometry = new RectangleGeometry(new Rect(0, 0, this.Bounds.Size.Width, this.Bounds.Size.Height)); + var rect = new Rect(this.Bounds.Size).Deflate(this.StrokeThickness); + this.geometry = new RectangleGeometry(rect); this.geometrySize = this.Bounds.Size; } diff --git a/Perspex.SceneGraph/Rect.cs b/Perspex.SceneGraph/Rect.cs index 5a0268ab9c..38eae3bd24 100644 --- a/Perspex.SceneGraph/Rect.cs +++ b/Perspex.SceneGraph/Rect.cs @@ -302,7 +302,7 @@ namespace Perspex /// The deflated rectangle size cannot be less than 0. public Rect Deflate(double thickness) { - return this.Deflate(new Thickness(thickness)); + return this.Deflate(new Thickness(thickness / 2)); } /// diff --git a/TestFiles/Direct2D1/Shapes/Rectangle/Rectangle_1px_Stroke.expected.png b/TestFiles/Direct2D1/Shapes/Rectangle/Rectangle_1px_Stroke.expected.png index 6aa013a894afc8d113567acc51767728aa94e17a..24239d5799ab3308d44bf2ab283758dc0202c9b3 100644 GIT binary patch delta 110 zcmeyu@{nbMqXoC8i(^Pd+}q0=1)CiNSPr)TDRw(I^9slBRkv@ll<_fuz=5FaIhARN zi}iU`8aG_MpMQVz0q%_xw=+(Bz@^@jz0GFxhKtkLz$zK0Sw3ffb%QnA_j}nTkcg+N KpUXO@geCwrel2JK delta 129 zcmaFJ@`YuBqnn(ki(^Pd+}q0sIS)JVFgRNGvX)Of*JFM9;7>`j3C~m6T0$Dim>EDI z;!557qQ0HaIK3