diff --git a/MLEM/Extensions/NumberExtensions.cs b/MLEM/Extensions/NumberExtensions.cs index 96c50ef..3b66648 100644 --- a/MLEM/Extensions/NumberExtensions.cs +++ b/MLEM/Extensions/NumberExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; using MLEM.Misc; @@ -158,6 +159,33 @@ namespace MLEM.Extensions { return rect; } + /// + /// Returns a set of values that are contained in the given . + /// Note that and are inclusive, but and are not. + /// + /// The area whose points to get + /// The points contained in the area + public static IEnumerable GetPoints(this Rectangle area) { + for (var x = area.Left; x < area.Right; x++) { + for (var y = area.Top; y < area.Bottom; y++) + yield return new Point(x, y); + } + } + + /// + /// Returns a set of values that are contained in the given . + /// Note that and are inclusive, but and are not. + /// + /// The area whose points to get + /// The distance that should be traveled between each point that is to be returned + /// The points contained in the area + public static IEnumerable GetPoints(this RectangleF area, float interval = 1) { + 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); + } + } + /// /// Turns the given 3-dimensional vector into a 2-dimensional vector by chopping off the z coordinate. ///