From 474ce9a44207b8d49758324fc0ec9d4bfe591e58 Mon Sep 17 00:00:00 2001 From: BobLd Date: Fri, 9 Aug 2019 19:58:48 +0100 Subject: [PATCH 1/3] Improving PdfPoint --- src/UglyToad.PdfPig/Geometry/PdfPoint.cs | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs index 260c5d66..312e61e4 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs @@ -82,6 +82,39 @@ return new PdfVector(X, Y); } + /// + /// Converts this into an array. + /// + /// + public double[] ToDouble() + { + return new double[] { (double)this.X, (double)this.Y }; + } + + /// + /// Returns a value indicating whether this is equal to a specified . + /// + /// + /// + public override bool Equals(object obj) + { + if (obj is PdfPoint) + { + PdfPoint point = (PdfPoint)obj; + return point.X == this.X && point.Y == this.Y; + } + return false; + } + + /// + /// Returns the hash code for this . + /// + /// + public override int GetHashCode() + { + return (int)(this.X * 10_000 + 31 * this.Y * 10_000); + } + /// /// Get a string representation of this point. /// From bd58879e32ae7bdbba47ba8656c09067b9b10227 Mon Sep 17 00:00:00 2001 From: BobLd Date: Sat, 10 Aug 2019 13:05:25 +0100 Subject: [PATCH 2/3] Update from comments --- src/UglyToad.PdfPig/Geometry/PdfPoint.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs index 312e61e4..539f7fd4 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs @@ -83,9 +83,8 @@ } /// - /// Converts this into an array. + /// Converts this into an double array. /// - /// public double[] ToDouble() { return new double[] { (double)this.X, (double)this.Y }; @@ -95,12 +94,10 @@ /// Returns a value indicating whether this is equal to a specified . /// /// - /// public override bool Equals(object obj) { - if (obj is PdfPoint) + if (obj is PdfPoint point) { - PdfPoint point = (PdfPoint)obj; return point.X == this.X && point.Y == this.Y; } return false; @@ -109,10 +106,9 @@ /// /// Returns the hash code for this . /// - /// public override int GetHashCode() { - return (int)(this.X * 10_000 + 31 * this.Y * 10_000); + return (X, Y).GetHashCode(); } /// From 9b24223190768fa19ec25b49cacd061e342a1468 Mon Sep 17 00:00:00 2001 From: BobLd Date: Sat, 10 Aug 2019 13:52:01 +0100 Subject: [PATCH 3/3] Removing ToDouble() --- src/UglyToad.PdfPig/Geometry/PdfPoint.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs index 539f7fd4..8ddc1bdf 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfPoint.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfPoint.cs @@ -82,14 +82,6 @@ return new PdfVector(X, Y); } - /// - /// Converts this into an double array. - /// - public double[] ToDouble() - { - return new double[] { (double)this.X, (double)this.Y }; - } - /// /// Returns a value indicating whether this is equal to a specified . ///