Struct ShapeDrawOptions
Describes a shape draw call in a renderer-agnostic way.
public readonly record struct ShapeDrawOptions : IEquatable<ShapeDrawOptions>
- Implements
- Inherited Members
Constructors
ShapeDrawOptions(ShapePrimitive, ReadOnlyMemory<Vector2>, Rectangle, Vector2, float, int, int, Color, int, Material, ReadOnlyMemory<Color>)
Creates a shape draw from its parts. The static methods make the usual shapes.
public ShapeDrawOptions(ShapePrimitive primitive, ReadOnlyMemory<Vector2> points, Rectangle rectangle, Vector2 center, float radius, int segments, int thickness, Color color, int zIndex = 0, Material material = default, ReadOnlyMemory<Color> colors = default)
Parameters
primitiveShapePrimitivepointsReadOnlyMemory<Vector2>rectangleRectanglecenterVector2radiusfloatsegmentsintthicknessintcolorColorzIndexintmaterialMaterialcolorsReadOnlyMemory<Color>
Exceptions
- ArgumentException
materialis a sprite material, which draws nothing for a shape.
Properties
Center
The centre of a circle.
public Vector2 Center { get; }
Property Value
Color
The colour of the shape. A triangle list uses Colors instead.
public Color Color { get; }
Property Value
Colors
The colour of each vertex of a triangle list, parallel to Points. Empty for the other shapes.
public ReadOnlyMemory<Color> Colors { get; }
Property Value
Material
The material the shape is drawn with. Shape when not given.
public Material Material { get; }
Property Value
Points
The points the shape is built from: the two ends of a line, the corners of a triangle, the position of a point, or the vertices of a triangle list. Empty for the other shapes.
public ReadOnlyMemory<Vector2> Points { get; }
Property Value
Primitive
The kind of shape to draw.
public ShapePrimitive Primitive { get; }
Property Value
Radius
The radius of a circle, in pixels.
public float Radius { get; }
Property Value
Rectangle
The rectangle that a rectangle shape covers.
public Rectangle Rectangle { get; }
Property Value
Segments
The number of straight sides a circle is drawn with.
public int Segments { get; }
Property Value
Thickness
The thickness of a line or outline, or the size of a point, in pixels. Zero for filled shapes.
public int Thickness { get; }
Property Value
ZIndex
The order the shape is drawn in, lower values first, within its pass.
public int ZIndex { get; }
Property Value
Methods
CircleFilled(Vector2, float, Color, int, int, Material)
A filled circle of radius around center, drawn with segments straight sides.
public static ShapeDrawOptions CircleFilled(Vector2 center, float radius, Color color, int segments = 30, int zIndex = 0, Material material = default)
Parameters
Returns
CircleOutline(Vector2, float, Color, int, int, int, Material)
An outline of a circle of radius around center, drawn with segments straight sides and thickness pixels wide.
public static ShapeDrawOptions CircleOutline(Vector2 center, float radius, Color color, int segments = 30, int thickness = 1, int zIndex = 0, Material material = default)
Parameters
Returns
Line(Vector2, Vector2, Color, int, int, Material)
A line from start to end, thickness pixels wide.
public static ShapeDrawOptions Line(Vector2 start, Vector2 end, Color color, int thickness = 1, int zIndex = 0, Material material = default)
Parameters
Returns
Point(Vector2, Color, int, int, Material)
A point at position, size pixels across.
public static ShapeDrawOptions Point(Vector2 position, Color color, int size = 1, int zIndex = 0, Material material = default)
Parameters
Returns
RectangleFilled(Rectangle, Color, int, Material)
A filled rectangle.
public static ShapeDrawOptions RectangleFilled(Rectangle rectangle, Color color, int zIndex = 0, Material material = default)
Parameters
Returns
RectangleOutline(Rectangle, Color, int, int, Material)
An outline of rectangle, thickness pixels wide.
public static ShapeDrawOptions RectangleOutline(Rectangle rectangle, Color color, int thickness = 1, int zIndex = 0, Material material = default)
Parameters
Returns
TriangleList(ReadOnlyMemory<Vector2>, ReadOnlyMemory<Color>, int, Material)
A triangle list carrying a color per vertex. points is taken three
at a time, and colors must be the same length.
public static ShapeDrawOptions TriangleList(ReadOnlyMemory<Vector2> points, ReadOnlyMemory<Color> colors, int zIndex = 0, Material material = default)
Parameters
pointsReadOnlyMemory<Vector2>colorsReadOnlyMemory<Color>zIndexintmaterialMaterial
Returns
Remarks
The GPU interpolates color across each triangle, so tessellating a region and evaluating a function per vertex draws any smooth fill with no texture or shader. Callers are expected to reuse their buffers so this costs nothing per frame.
TriangleOutline(Vector2, Vector2, Vector2, Color, int, int, Material)
An outline of the triangle with corners point1, point2 and point3, thickness pixels wide.
public static ShapeDrawOptions TriangleOutline(Vector2 point1, Vector2 point2, Vector2 point3, Color color, int thickness = 1, int zIndex = 0, Material material = default)