Class Shapes
Provides implementations of various shape algorithms which are useful for for generating points representing shapes on a 2D integer grid.
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public static class Shapes : Object
Methods
GetBox(Rectangle)
Gets the points on the outside of a box defined by the outer edges of the given rectangle.
Declaration
public static RectanglePerimeterPositionsEnumerator GetBox(Rectangle rectangle)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rectangle | A rectangle whose outer edges define the box to iterate over. |
Returns
Type | Description |
---|---|
RectanglePerimeterPositionsEnumerator | Every point on the outer edges of the box specified. |
Remarks
This function returns a custom iterator which is very fast when used in a foreach loop. If you need an IEnumerable to use with LINQ or other code, the returned struct does implement that interface; however note that iterating over it this way will not perform as well as iterating directly over this object.
GetCircle(Point, Int32)
Gets the points on the outside of a circle.
Declaration
public static CirclePositionsEnumerator GetCircle(Point center, int radius)
Parameters
Type | Name | Description |
---|---|---|
Point | center | Center of the circle. |
Int32 | radius | The radius of the circle. |
Returns
Type | Description |
---|---|
CirclePositionsEnumerator | Every point on the outer edges of the circle specified. |
Remarks
This function returns a custom iterator which is very fast when used in a foreach loop. If you need an IEnumerable to use with LINQ or other code, the returned struct does implement that interface; however note that iterating over it this way will not perform as well as iterating directly over this object.
GetEllipse(Point, Point)
Gets the points on the outside of an ellipse.
Declaration
public static EllipsePositionsEnumerator GetEllipse(Point f1, Point f2)
Parameters
Type | Name | Description |
---|---|---|
Point | f1 | The first focus point of the ellipse. |
Point | f2 | The second focus point of the ellipse. |
Returns
Type | Description |
---|---|
EllipsePositionsEnumerator | Every point on the outer edges of the ellipse specified. |
Remarks
This function returns a custom iterator which is very fast when used in a foreach loop. If you need an IEnumerable to use with LINQ or other code, the returned struct does implement that interface; however note that iterating over it this way will not perform as well as iterating directly over this object.