diff --git a/CHANGELOG.md b/CHANGELOG.md index 79bcc0c..1c2d0b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Jump to version: ### MLEM Additions - **Added the ability for formatted (tokenized) strings to be drawn with custom rotation, origin and flipping** +- Added a RectangleF.FromCorners overload that accepts points Improvements - Allow NumberExtensions.GetPoints to include bottom and right coordinates diff --git a/MLEM/Misc/RectangleF.cs b/MLEM/Misc/RectangleF.cs index 8473f3a..95890a5 100644 --- a/MLEM/Misc/RectangleF.cs +++ b/MLEM/Misc/RectangleF.cs @@ -264,7 +264,7 @@ namespace MLEM.Misc { /// /// The first corner to use /// The second corner to use - /// + /// The created rectangle. public static RectangleF FromCorners(Vector2 corner1, Vector2 corner2) { var minX = Math.Min(corner1.X, corner2.X); var minY = Math.Min(corner1.Y, corner2.Y); @@ -273,6 +273,21 @@ namespace MLEM.Misc { return new RectangleF(minX, minY, maxX - minX, maxY - minY); } + /// + /// Creates a new rectangle based on two corners that form a bounding box. + /// The resulting rectangle will encompass both corners as well as all of the space between them. + /// + /// The first corner to use + /// The second corner to use + /// The created rectangle. + public static RectangleF FromCorners(Point corner1, Point corner2) { + var minX = Math.Min(corner1.X, corner2.X); + var minY = Math.Min(corner1.Y, corner2.Y); + var maxX = Math.Max(corner1.X, corner2.X); + var maxY = Math.Max(corner1.Y, corner2.Y); + return new RectangleF(minX, minY, maxX - minX, maxY - minY); + } + /// /// Converts an int-based rectangle to a float-based rectangle. ///