From ba7059f4ef479f65d105e123824715e2588cb4a3 Mon Sep 17 00:00:00 2001 From: Lehonti Ramos Date: Wed, 9 Aug 2023 20:18:25 +0200 Subject: [PATCH] Made more methods `readonly` --- Pinta.Core/Classes/Rectangle.cs | 6 +++--- Pinta.Core/Classes/ScaleFactor.cs | 32 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Pinta.Core/Classes/Rectangle.cs b/Pinta.Core/Classes/Rectangle.cs index 8f0b8e8c6..6b6ab9053 100644 --- a/Pinta.Core/Classes/Rectangle.cs +++ b/Pinta.Core/Classes/Rectangle.cs @@ -69,7 +69,7 @@ public readonly bool ContainsPoint (double x, double y) return true; } - public bool ContainsPoint (in PointD point) => ContainsPoint (point.X, point.Y); + public readonly bool ContainsPoint (in PointD point) => ContainsPoint (point.X, point.Y); public readonly PointD Location () => new (X, Y); public readonly PointD GetCenter () => new (X + 0.5 * Width, Y + 0.5 * Height); @@ -154,12 +154,12 @@ public static RectangleI FromLTRB (int left, int top, int right, int bottom) public override readonly string ToString () => $"x:{X} y:{Y} w:{Width} h:{Height}"; - public bool Contains (int x, int y) + public readonly bool Contains (int x, int y) { return x >= Left && x <= Right && y >= Top && y <= Bottom; } - public bool Contains (in PointI pt) => Contains (pt.X, pt.Y); + public readonly bool Contains (in PointI pt) => Contains (pt.X, pt.Y); public readonly RectangleI Intersect (RectangleI r) => Intersect (this, r); diff --git a/Pinta.Core/Classes/ScaleFactor.cs b/Pinta.Core/Classes/ScaleFactor.cs index 8d2b7b1c3..98d17bde8 100644 --- a/Pinta.Core/Classes/ScaleFactor.cs +++ b/Pinta.Core/Classes/ScaleFactor.cs @@ -168,62 +168,62 @@ public readonly double UnscaleScalar (double x) return (x * (double) denominator) / (double) numerator; } - public PointI ScalePoint (PointI p) + public readonly PointI ScalePoint (PointI p) { return new PointI (ScaleScalar (p.X), ScaleScalar (p.Y)); } - public PointD ScalePoint (PointD p) + public readonly PointD ScalePoint (PointD p) { return new PointD (ScaleScalar (p.X), ScaleScalar (p.Y)); } - public PointD ScalePointJustX (PointD p) + public readonly PointD ScalePointJustX (PointD p) { return new PointD (ScaleScalar (p.X), p.Y); } - public PointD ScalePointJustY (PointD p) + public readonly PointD ScalePointJustY (PointD p) { return new PointD (p.X, ScaleScalar (p.Y)); } - public PointD UnscalePoint (PointD p) + public readonly PointD UnscalePoint (PointD p) { return new PointD (UnscaleScalar (p.X), UnscaleScalar (p.Y)); } - public PointD UnscalePointJustX (PointD p) + public readonly PointD UnscalePointJustX (PointD p) { return new PointD (UnscaleScalar (p.X), p.Y); } - public PointD UnscalePointJustY (PointD p) + public readonly PointD UnscalePointJustY (PointD p) { return new PointD (p.X, UnscaleScalar (p.Y)); } - public PointI ScalePointJustX (PointI p) + public readonly PointI ScalePointJustX (PointI p) { return new PointI (ScaleScalar (p.X), p.Y); } - public PointI ScalePointJustY (PointI p) + public readonly PointI ScalePointJustY (PointI p) { return new PointI (p.X, ScaleScalar (p.Y)); } - public PointI UnscalePoint (PointI p) + public readonly PointI UnscalePoint (PointI p) { return new PointI (UnscaleScalar (p.X), UnscaleScalar (p.Y)); } - public PointI UnscalePointJustX (PointI p) + public readonly PointI UnscalePointJustX (PointI p) { return new PointI (UnscaleScalar (p.X), p.Y); } - public PointI UnscalePointJustY (PointI p) + public readonly PointI UnscalePointJustY (PointI p) { return new PointI (p.X, UnscaleScalar (p.Y)); } @@ -238,12 +238,12 @@ public PointI UnscalePointJustY (PointI p) // return new SizeF(UnscaleScalar(s.Width), UnscaleScalar(s.Height)); //} - public Size ScaleSize (Size s) + public readonly Size ScaleSize (Size s) { return new Size (ScaleScalar (s.Width), ScaleScalar (s.Height)); } - public Size UnscaleSize (Size s) + public readonly Size UnscaleSize (Size s) { return new Size (UnscaleScalar (s.Width), UnscaleScalar (s.Height)); } @@ -258,12 +258,12 @@ public Size UnscaleSize (Size s) // return new RectangleF(UnscalePoint(rectF.Location), UnscaleSize(rectF.Size)); //} - public RectangleI ScaleRectangle (RectangleI rect) + public readonly RectangleI ScaleRectangle (RectangleI rect) { return new RectangleI (ScalePoint (rect.Location), ScaleSize (rect.Size)); } - public RectangleI UnscaleRectangle (RectangleI rect) + public readonly RectangleI UnscaleRectangle (RectangleI rect) { return new RectangleI (UnscalePoint (rect.Location), UnscaleSize (rect.Size)); }