Method GetSpiralIterator
GetSpiralIterator(IImplicitShape<GridPoint2>, GridPoint2, int)
Get's an enumerable of shape points in a spiral outwards from a given point, assuming the points are coordinates of a hex grid.
public static IEnumerable<GridPoint2> GetSpiralIterator(IImplicitShape<GridPoint2> shape, GridPoint2 origin, int ringCount)
Parameters
shapeIImplicitShape<GridPoint2>The shape to return points from.
originGridPoint2Where the spiral should start.
ringCountintHow many rings there should be in the spiral. The origin is the first ring, so when ringCount is 1, only the origin will be returned.
Returns
Remarks
note
Remember that IExplicitShape<TPoint>, IGrid<TPoint, TCell> and Grid2<TCell> all are also of type IImplicitShape<TPoint>, so this method can be used with explicit shapes and grids too.
tip
You can transform the grid shape to get transformed spirals, such as spirals going in the opposite direction, using ReverseSelect<TPoint>(IImplicitShape<TPoint>, Func<TPoint, TPoint>). For example:
var reverseSpiral = PointyHexPoint
.GetSpiralIterator(
grid.ReverseSelect(p => PointyHexPoint.ReflectAboutX(p)),
center,
radius);