Skip to content

Commit

Permalink
Made more methods readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehonti Ramos committed Aug 9, 2023
1 parent cb92af1 commit ba7059f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Pinta.Core/Classes/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
32 changes: 16 additions & 16 deletions Pinta.Core/Classes/ScaleFactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand Down

0 comments on commit ba7059f

Please sign in to comment.