mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-28 07:18:35 +01:00
Compare commits
No commits in common. "85d20b64336da6b5a7de35b0dafd68be6d4cf88e" and "dd9230abf05095c17d8231f7e929adacd0fcadca" have entirely different histories.
85d20b6433
...
dd9230abf0
3 changed files with 11 additions and 46 deletions
|
@ -18,10 +18,6 @@ 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
|
|
||||||
- Allow NumberExtensions.GetPoints to include bottom and right coordinates
|
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
Additions
|
Additions
|
||||||
|
|
|
@ -166,44 +166,28 @@ namespace MLEM.Extensions {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a set of <see cref="Point"/> values that are contained in the given <see cref="Rectangle"/>.
|
/// Returns a set of <see cref="Point"/> values that are contained in the given <see cref="Rectangle"/>.
|
||||||
/// Note that, by default, <see cref="Rectangle.Left"/> and <see cref="Rectangle.Top"/> are inclusive, but <see cref="Rectangle.Right"/> and <see cref="Rectangle.Bottom"/> are not.
|
/// Note that <see cref="Rectangle.Left"/> and <see cref="Rectangle.Top"/> are inclusive, but <see cref="Rectangle.Right"/> and <see cref="Rectangle.Bottom"/> are not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="area">The area whose points to get</param>
|
/// <param name="area">The area whose points to get</param>
|
||||||
/// <param name="bottomRightInclusive">Whether <see cref="Rectangle.Right"/> and <see cref="Rectangle.Bottom"/> should be inclusive, rather than exclusive.</param>
|
|
||||||
/// <returns>The points contained in the area</returns>
|
/// <returns>The points contained in the area</returns>
|
||||||
public static IEnumerable<Point> GetPoints(this Rectangle area, bool bottomRightInclusive = false) {
|
public static IEnumerable<Point> GetPoints(this Rectangle area) {
|
||||||
if (bottomRightInclusive) {
|
for (var x = area.Left; x < area.Right; x++) {
|
||||||
for (var x = area.Left; x <= area.Right; x++) {
|
for (var y = area.Top; y < area.Bottom; y++)
|
||||||
for (var y = area.Top; y <= area.Bottom; y++)
|
yield return new Point(x, y);
|
||||||
yield return new Point(x, y);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var x = area.Left; x < area.Right; x++) {
|
|
||||||
for (var y = area.Top; y < area.Bottom; y++)
|
|
||||||
yield return new Point(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a set of <see cref="Vector2"/> values that are contained in the given <see cref="RectangleF"/>.
|
/// Returns a set of <see cref="Vector2"/> values that are contained in the given <see cref="RectangleF"/>.
|
||||||
/// Note that, by default, <see cref="RectangleF.Left"/> and <see cref="RectangleF.Top"/> are inclusive, but <see cref="RectangleF.Right"/> and <see cref="RectangleF.Bottom"/> are not.
|
/// Note that <see cref="RectangleF.Left"/> and <see cref="RectangleF.Top"/> are inclusive, but <see cref="RectangleF.Right"/> and <see cref="RectangleF.Bottom"/> are not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="area">The area whose points to get</param>
|
/// <param name="area">The area whose points to get</param>
|
||||||
/// <param name="interval">The distance that should be traveled between each point that is to be returned</param>
|
/// <param name="interval">The distance that should be traveled between each point that is to be returned</param>
|
||||||
/// <param name="bottomRightInclusive">Whether <see cref="RectangleF.Right"/> and <see cref="RectangleF.Bottom"/> should be inclusive, rather than exclusive.</param>
|
|
||||||
/// <returns>The points contained in the area</returns>
|
/// <returns>The points contained in the area</returns>
|
||||||
public static IEnumerable<Vector2> GetPoints(this RectangleF area, float interval = 1, bool bottomRightInclusive = false) {
|
public static IEnumerable<Vector2> GetPoints(this RectangleF area, float interval = 1) {
|
||||||
if (bottomRightInclusive) {
|
for (var x = area.Left; x < area.Right; x += interval) {
|
||||||
for (var x = area.Left; x <= area.Right; x += interval) {
|
for (var y = area.Top; y < area.Bottom; y += interval)
|
||||||
for (var y = area.Top; y <= area.Bottom; y += interval)
|
yield return new Vector2(x, y);
|
||||||
yield return new Vector2(x, y);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var x = area.Left; x < area.Right; x += interval) {
|
|
||||||
for (var y = area.Top; y < area.Bottom; y += interval)
|
|
||||||
yield return new Vector2(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>The created rectangle.</returns>
|
/// <returns></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,21 +273,6 @@ 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