mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
Added a RectangleF.FromCorners overload that accepts points
This commit is contained in:
parent
7bf418f8b2
commit
85d20b6433
2 changed files with 17 additions and 1 deletions
|
@ -18,6 +18,7 @@ Jump to version:
|
||||||
### MLEM
|
### MLEM
|
||||||
Additions
|
Additions
|
||||||
- **Added the ability for formatted (tokenized) strings to be drawn with custom rotation, origin and flipping**
|
- **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
|
Improvements
|
||||||
- Allow NumberExtensions.GetPoints to include bottom and right coordinates
|
- Allow NumberExtensions.GetPoints to include bottom and right coordinates
|
||||||
|
|
|
@ -264,7 +264,7 @@ namespace MLEM.Misc {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="corner1">The first corner to use</param>
|
/// <param name="corner1">The first corner to use</param>
|
||||||
/// <param name="corner2">The second corner to use</param>
|
/// <param name="corner2">The second corner to use</param>
|
||||||
/// <returns></returns>
|
/// <returns>The created rectangle.</returns>
|
||||||
public static RectangleF FromCorners(Vector2 corner1, Vector2 corner2) {
|
public static RectangleF FromCorners(Vector2 corner1, Vector2 corner2) {
|
||||||
var minX = Math.Min(corner1.X, corner2.X);
|
var minX = Math.Min(corner1.X, corner2.X);
|
||||||
var minY = Math.Min(corner1.Y, corner2.Y);
|
var minY = Math.Min(corner1.Y, corner2.Y);
|
||||||
|
@ -273,6 +273,21 @@ namespace MLEM.Misc {
|
||||||
return new RectangleF(minX, minY, maxX - minX, maxY - minY);
|
return new RectangleF(minX, minY, maxX - minX, maxY - minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="corner1">The first corner to use</param>
|
||||||
|
/// <param name="corner2">The second corner to use</param>
|
||||||
|
/// <returns>The created rectangle.</returns>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts an int-based rectangle to a float-based rectangle.
|
/// Converts an int-based rectangle to a float-based rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue