Table of Contents

Class ShapeBatch

Namespace
Stride.CommunityToolkit.Shapes
Assembly
Stride.CommunityToolkit.Shapes.dll

Immediate-mode drawing of filled convex shapes whose outline stays a constant number of pixels wide at any zoom, distance or window size, because the shader measures it per fragment from a signed distance function instead of building it as geometry. "Pixels" here means pixels on a 100% display: the widths follow the display's scale by default (see AutoScale), so they are the same size to the eye everywhere.

public sealed class ShapeBatch : RenderObject
Inheritance
ShapeBatch
Inherited Members

Remarks

Shapes are flat, but they can sit anywhere in 3D: on a plane you choose, facing the camera, or swung about an axis so a capsule reads as a thick 3D line. Every shape submitted in a frame goes out in a single instanced draw call, however many there are.

Submit shapes every frame from your update logic; they are drawn once, blended in submission order, and the batch resets itself after rendering. Register with game.AddShapeBatch().

BorderWidth, StrokeWidth, Fill, Glow, Dash, Gradient, Opacity, DepthFade, Textured, Screen and Tag are current state, captured by each draw call as it is made, so you can change them between calls the way you would with a sprite batch.

Properties

AutoScale

Whether the pixel-measured widths - border, glow, dashes, pixel lines - follow the display's scale, so a 2-pixel border is the same width to the eye on a 150% laptop as on a 100% monitor. Defaults to true.

public bool AutoScale { get; set; }

Property Value

bool

Remarks

The scale comes from DisplayScale, shared with the rest of the toolkit, and is re-read when the window moves to another monitor. Turn this off to get exactly the pixels asked for, such as for a screenshot at a known size. World-unit sizes are never affected.

BorderWidth

Outline width in on-screen pixels around a filled shape, constant at any zoom or distance. The default of 0 is a borderless fill the exact size of the shape; the Box2D testbed look uses 3. Captured by each draw call as it is made.

public float BorderWidth { get; set; }

Property Value

float

Remarks

The border is centred on the shape's edge: half its width lies outside, so with 3 a shape is 3 pixels wider and taller than its size. The shapes that are all stroke, the rings and the arcs drawn without a width, take StrokeWidth instead.

CanPick

Whether a pick can be answered yet: the batch has been drawn at least once, so it knows the view. False on the first frame.

public bool CanPick { get; }

Property Value

bool

Count

How many records have been submitted so far this frame. Resets to zero once the batch is drawn, so read it after your own submissions and before the frame ends.

public int Count { get; }

Property Value

int

Remarks

A record is what the GPU draws as one instance. Most draw calls submit one; a polyline of more than 64 points submits one per piece, and a wire box one per edge.

Dash

The dash pattern along outlines - length, gap and phase in on-screen pixels. A length of 0, the default, draws solid. Circles, arcs and lines dash; polygons stay solid. See DashPattern. Captured by each draw call as it is made.

public DashPattern Dash { get; }

Property Value

DashPattern

DepthFade

Distance in world units over which a shape fades out as it approaches scene geometry, instead of cutting off at the depth test. The default 0 keeps the hard cut. Captured by each draw call as it is made.

public float DepthFade { get; set; }

Property Value

float

Remarks

A disc on an uneven floor fades where the floor rises through it; a ring crossing a wall dissolves into the wall rather than being sliced by it. The same idea as soft particles: the shader compares its own distance from the camera with the scene's at the same pixel.

It needs the depth the forward renderer resolves before the transparent stage, which is on by default; where a compositor turns that off the fade has nothing to read and the shape keeps its hard cut. On an overlay batch a fragment behind the surface fades to nothing too, which makes the fade a soft depth test of its own.

The distance is in world units under a perspective camera. Under an orthographic camera the fade is much stronger than the figure asks for.

DepthTest

Whether shapes are tested against the depth buffer, so scene geometry can occlude them. They never write depth. The default is false, which draws them as an overlay on top of everything - what you want for gizmos and 2D scenes, but not for decals on the ground.

public bool DepthTest { get; set; }

Property Value

bool

Remarks

This applies to the whole batch. Call game.AddShapeBatch() a second time for a batch with the other setting when you need both in one scene.

Fill

How the interior is painted: the fill's own colour, or null for the outline colour, and its intensity. The default is the outline colour at full intensity, so a draw call with one colour draws a solid shape. See ShapeFill. Captured by each draw call as it is made.

public ShapeFill Fill { get; }

Property Value

ShapeFill

FillSource

The fill source every textured shape in this batch samples: one of Stride's material nodes, such as a ComputeTextureColor with a texture, a scale, an offset and address modes, a blend of two nodes, or a custom shader class. null, the default, is a plain batch. See FillWith(Texture, Vector2?, Vector2?, TextureAddressMode) for the common case.

public IComputeColor? FillSource { get; set; }

Property Value

IComputeColor

Remarks

The sample multiplies the fill colour, alpha included: a white fill shows the image as it is, a tint darkens it, Alpha fades it and a Gradient still runs over it. The border and the glow are untouched. The texture spans the shape's bounding box, (0,0) at the top left; a thick border reaches a little past the box, where the node's address mode decides what shows.

It is one source per batch, because a shader composition is resolved when the effect is built. Assigning a different node reloads the effect once; changing a node's own properties - its texture, scale or offset - is picked up the next frame with no reload, which is how a scrolling stripe animates. Shapes drawn with Textured off ignore it.

Glow

A soft glow outside the outline - width in pixels, and a colour or null for the outline's. See ShapeGlow. Captured by each draw call as it is made.

public ShapeGlow Glow { get; }

Property Value

ShapeGlow

Gradient

A gradient across the fill: the colour it runs to and the direction. Gradient.Color left null, the default, is a flat fill. See FillGradient. Captured by each draw call as it is made.

public FillGradient Gradient { get; }

Property Value

FillGradient

Opacity

A multiplier on everything a shape draws - border, fill and glow alike - from 0 to 1. The default 1 changes nothing. Captured by each draw call as it is made.

public float Opacity { get; set; }

Property Value

float

Remarks

This is how a widget goes disabled or fades in: one assignment, rather than an alpha edit on each of its colours. It multiplies the alpha the colours already carry, so a fill at half alpha under an opacity of a half draws at a quarter.

Screen

Whether draw calls place their shapes in pixels on the screen rather than in the world: coordinates from the top left of the viewport, Y down, like a sprite, and drawn over everything else in the batch whatever its depth test says. Defaults to false. Captured by each draw call as it is made, so a HUD and the world it sits over come from one batch, in submission order.

public bool Screen { get; set; }

Property Value

bool

Remarks

The Vector2 overloads are the natural ones here; a Vector3 position's Z is ignored, and a plane's axes are read as pixel axes. A thick line lies flat on the screen and a billboard is axis-aligned. Because Y runs down, a positive angle turns clockwise on screen, as it does for a sprite. Space strokes are not screen shapes.

The coordinates are the display's scaled pixels when AutoScale is on, so a layout is the same size to the eye on every display, and AnchorPoint(Anchor) and ScreenSize speak the same units. A pixel-measured width, a dash or a glow means exactly what it means in the world.

ScreenSize

The viewport's size in the pixels screen shapes use - the display's scaled pixels when AutoScale is on. Zero for a batch that was not registered through game.AddShapeBatch() and so has no window to ask.

public Vector2 ScreenSize { get; }

Property Value

Vector2

StrokeWidth

Width in on-screen pixels of the shapes that are all stroke: DrawRing(Vector3, Vector3, float, Color), DrawPixelRing(Vector3, float, Color) and DrawArc(Vector3, Vector3, float, float, float, Color, float) without a width. Defaults to 1, independent of BorderWidth, so a borderless fill and a visible ring coexist. Captured by each draw call as it is made.

public float StrokeWidth { get; set; }

Property Value

float

Tag

The tag every shape drawn from now on carries, or null (the default) for shapes that cannot be picked. Current state captured per draw call, like Fill or Glow: set it, draw, set the next one. A hit hands the tag back as Tag, so it is whatever the caller wants to get back - a station, an index, a button. Only tagged shapes are recorded for picking; a batch that never tags pays nothing.

public object? Tag { get; set; }

Property Value

object

Textured

Whether draw calls sample FillSource. Defaults to true, so setting a fill source textures everything; turn it off around the shapes that should keep a flat fill, the way any other state is switched between draw calls. Without a fill source it does nothing.

public bool Textured { get; set; }

Property Value

bool

Viewport

A rectangle of the screen, in pixels from the top left, that screen shapes are placed relative to: a chart draws in its own coordinates and lands where the rectangle is. The default null is the whole viewport. The rectangle offsets and sizes AnchorPoint(Anchor); nothing is clipped to it.

public RectangleF? Viewport { get; set; }

Property Value

RectangleF?

Methods

AnchorPoint(Anchor)

The pixel position of a point of what screen shapes draw into - the Viewport rectangle when one is set, otherwise the screen - so a widget is placed as an anchor plus an offset rather than by a hardcoded resolution.

public Vector2 AnchorPoint(Anchor anchor)

Parameters

anchor Anchor

Which point: a corner, the middle of an edge or the centre.

Returns

Vector2

The point, in the same coordinates the draw calls take.

DrawAnnulus(Vector2, float, float, Color)

Submits a filled ring in the XY plane, the 2D case of DrawAnnulus(Vector3, Vector3, float, float, Color).

public void DrawAnnulus(Vector2 center, float outerRadius, float innerRadius, Color color)

Parameters

center Vector2

World-space centre.

outerRadius float

Outer radius in world units.

innerRadius float

Radius of the hole in world units, smaller than the outer one.

color Color

The outline colour, and the fill colour unless Color is set.

DrawAnnulus(Vector3, Vector3, float, float, Color)

Submits a filled ring - a disc with a hole - lying flat in the plane a normal defines, with the outline drawn around both edges. A donut, a range band, a thick unit ring.

public void DrawAnnulus(Vector3 center, Vector3 normal, float outerRadius, float innerRadius, Color color)

Parameters

center Vector3

World-space centre.

normal Vector3

Normal of the plane the annulus lies in.

outerRadius float

Outer radius in world units.

innerRadius float

Radius of the hole in world units, smaller than the outer one.

color Color

The outline colour, and the fill colour unless Color is set.

DrawArc(Vector2, float, float, float, Color, float)

Submits an arc of a circle with round ends in the XY plane, the 2D case of DrawArc(Vector3, Vector3, float, float, float, Color, float). Angles are counter-clockwise from the X axis.

public void DrawArc(Vector2 center, float radius, float startAngle, float sweepAngle, Color color, float width = 0)

Parameters

center Vector2

World-space centre of the circle.

radius float

Radius of the arc's centreline in world units.

startAngle float

Where the arc starts, in radians from the X axis.

sweepAngle float

How far it extends, in radians. Positive is counter-clockwise, negative clockwise; a full turn or more closes the ring.

color Color

The outline colour; with a width the fill derives from it and Alpha.

width float

Width of the band in world units, or 0 (the default) for a stroke StrokeWidth pixels wide.

DrawArc(Vector3, Vector3, float, float, float, Color, float)

Submits an arc of a circle with round ends, lying flat in the plane a normal defines. With no width it is a stroke the border's pixel width - a partial DrawRing(Vector3, Vector3, float, Color); with one it is a filled, outlined band of that world width centred on the radius - a radial progress bar.

public void DrawArc(Vector3 center, Vector3 normal, float radius, float startAngle, float sweepAngle, Color color, float width = 0)

Parameters

center Vector3

World-space centre of the circle.

normal Vector3

Normal of the plane the arc lies in.

radius float

Radius of the arc's centreline in world units.

startAngle float

Where the arc starts, in radians. Zero is along the plane's X axis; see DrawSector(Vector3, Vector3, float, float, float, Color, float).

sweepAngle float

How far it extends, in radians. Positive is counter-clockwise, negative clockwise; a full turn or more closes the ring.

color Color

The outline colour; with a width the fill derives from it and Alpha.

width float

Width of the band in world units, or 0 (the default) for a stroke StrokeWidth pixels wide.

Remarks

The ends are semicircles, which is what a progress ring wants. For square, radial ends use DrawSector(Vector3, Vector3, float, float, float, Color, float) with an inner radius.

DrawBillboard(ReadOnlySpan<Vector2>, Vector3, Color, float)

Submits a convex polygon that always faces the camera, screen-aligned - a marker that keeps its shape and orientation from any viewpoint.

public void DrawBillboard(ReadOnlySpan<Vector2> vertices, Vector3 position, Color color, float radius = 0)

Parameters

vertices ReadOnlySpan<Vector2>

The corners in local space, counter-clockwise.

position Vector3

World position of the shape's centre.

color Color

The outline colour, and the fill colour unless Color is set.

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

No vertices were given.

DrawBillboardCircle(Vector3, float, Color)

Submits a camera-facing circle: a point marker that stays perfectly round from any angle.

public void DrawBillboardCircle(Vector3 center, float radius, Color color)

Parameters

center Vector3

World-space centre.

radius float

Radius in world units.

color Color

The outline colour, and the fill colour unless Color is set.

DrawDisc(Vector2, float, Color)

Submits a filled disc in the XY plane, the 2D case.

public void DrawDisc(Vector2 center, float radius, Color color)

Parameters

center Vector2

Centre in the XY plane.

radius float

Radius in world units, or pixels with Screen on.

color Color

The outline colour, and the fill colour unless Color is set.

DrawDisc(Vector3, Vector3, float, Color)

Submits a filled disc lying flat in the plane a normal defines - a ground marker, an area-of-effect indicator, a decal.

public void DrawDisc(Vector3 center, Vector3 normal, float radius, Color color)

Parameters

center Vector3

World-space centre.

normal Vector3

Normal of the plane the disc lies in.

radius float

Radius in world units.

color Color

The outline colour, and the fill colour unless Color is set.

DrawLine(Vector2, Vector2, float, Color)

Submits a thick line in the XY plane, the 2D case.

public void DrawLine(Vector2 start, Vector2 end, float width, Color color)

Parameters

start Vector2

Start point in the XY plane.

end Vector2

End point in the XY plane.

width float

Line width in world units, or pixels with Screen on.

color Color

The line colour.

DrawLine(Vector3, Vector3, float, Color)

Submits a thick line between two points in 3D: a capsule swung about its own axis to face the camera, so it reads as a round-capped line of the width you ask for from any angle.

public void DrawLine(Vector3 start, Vector3 end, float width, Color color)

Parameters

start Vector3

World-space start point.

end Vector3

World-space end point.

width float

Line width in world units.

color Color

The line colour.

Remarks

Unlike hardware line rendering, which clamps to one pixel on most drivers, this is a real world-space width. The line is drawn solid, ignoring Alpha.

DrawPixelDisc(Vector3, float, Color)

Submits a camera-facing disc whose radius is measured in pixels on screen, so it is the same size at any distance - a marker or a scatter point that never shrinks as the camera pulls back.

public void DrawPixelDisc(Vector3 center, float pixelRadius, Color color)

Parameters

center Vector3

World position of the centre.

pixelRadius float

Radius in pixels on a 100% display; follows the display scale like the border width.

color Color

The outline colour; the fill derives from it and ShapeFill.

Remarks

Pixel-measured shapes are always billboards: the conversion from pixels to world units is exact only in a screen-aligned plane.

DrawPixelLine(Vector2, Vector2, float, Color)

Submits a line in the XY plane, the 2D case, pixelWidth on-screen pixels wide.

public void DrawPixelLine(Vector2 start, Vector2 end, float pixelWidth, Color color)

Parameters

start Vector2

Start point in the XY plane.

end Vector2

End point in the XY plane.

pixelWidth float

Line width in on-screen pixels.

color Color

The line colour.

DrawPixelLine(Vector3, Vector3, float, Color)

Submits a line whose width is measured in on-screen pixels rather than world units, so it keeps exactly the same thickness however far away it is - grid lines, axis rules, leader lines, anything that should read as drawn on the screen rather than placed in the scene.

public void DrawPixelLine(Vector3 start, Vector3 end, float pixelWidth, Color color)

Parameters

start Vector3

World-space start point.

end Vector3

World-space end point.

pixelWidth float

Line width in on-screen pixels.

color Color

The line colour.

Remarks

This is DrawLine(Vector3, Vector3, float, Color) with its world width collapsed to nothing, which leaves the outline - already measured in pixels - drawing the whole line. BorderWidth and Alpha do not apply; pixelWidth is the width.

DrawPixelPolyline(ReadOnlySpan<Vector2>, Vector3, Vector3, Vector3, float, Color, bool)

Submits a run of points as one stroke a constant number of pixels wide at any distance, with round joins and caps - the DrawPixelLine(Vector3, Vector3, float, Color) of curves and frames.

public void DrawPixelPolyline(ReadOnlySpan<Vector2> points, Vector3 position, Vector3 axisX, Vector3 axisY, float pixelWidth, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector2>

The run, in the plane's own coordinates, of any length.

position Vector3

World position of the plane's origin.

axisX Vector3

The plane's X axis. Normalized for you.

axisY Vector3

The plane's Y axis. Normalized for you.

pixelWidth float

Stroke width in pixels on a 100% display.

color Color

The stroke colour.

closed bool

Whether the last point joins back to the first.

DrawPixelPolyline(ReadOnlySpan<Vector2>, float, Color, bool)

public void DrawPixelPolyline(ReadOnlySpan<Vector2> points, float pixelWidth, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector2>
pixelWidth float
color Color
closed bool

DrawPixelPolyline(ReadOnlySpan<Vector3>, float, Color, bool)

Submits a run of points anywhere in 3D as one stroke a constant number of pixels wide at any distance, with round joins and caps - the DrawPixelLine(Vector3, Vector3, float, Color) of space curves, and what a trail through a 3D scene is drawn with.

public void DrawPixelPolyline(ReadOnlySpan<Vector3> points, float pixelWidth, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector3>

The run, in world space, of any length.

pixelWidth float

Stroke width in pixels on a 100% display.

color Color

The stroke colour.

closed bool

Whether the last point joins back to the first.

Remarks

Same behaviour and limits as DrawPolyline(ReadOnlySpan<Vector3>, float, Color, bool): per-fragment depth, pieces of 64 points with the dash pattern restarting at each, no crossing of the near plane.

DrawPixelRing(Vector3, float, Color)

Submits a camera-facing ring whose radius is measured in pixels on screen, stroked StrokeWidth pixels wide - a cursor marker or a selection halo that keeps its size at any distance.

public void DrawPixelRing(Vector3 center, float pixelRadius, Color color)

Parameters

center Vector3

World position of the centre.

pixelRadius float

Radius of the stroke's centreline in pixels on a 100% display.

color Color

The stroke colour.

DrawPolyline(ReadOnlySpan<Vector2>, Vector3, Vector3, Vector3, float, Color, bool)

Submits a run of points as one stroke of a world-space width, with round joins and caps - a plotted curve, a path, the outline of any shape including a concave one.

public void DrawPolyline(ReadOnlySpan<Vector2> points, Vector3 position, Vector3 axisX, Vector3 axisY, float width, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector2>

The run, in the plane's own coordinates, of any length.

position Vector3

World position of the plane's origin.

axisX Vector3

The plane's X axis. Normalized for you.

axisY Vector3

The plane's Y axis. Normalized for you.

width float

Stroke width in world units.

color Color

The stroke colour. Drawn solid, ignoring Alpha.

closed bool

Whether the last point joins back to the first.

Remarks

Joins are round: the stroke is everything within half the width of the run itself, drawn as one shape. Only a run of more than 64 points is split, into pieces that share a point; where two pieces meet the round cap is drawn twice, which shows as a slightly brighter dot when the stroke is translucent or has an additive glow. Dash runs along the whole run.

DrawPolyline(ReadOnlySpan<Vector2>, float, Color, bool)

public void DrawPolyline(ReadOnlySpan<Vector2> points, float width, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector2>
width float
color Color
closed bool

DrawPolyline(ReadOnlySpan<Vector3>, float, Color, bool)

Submits a run of points anywhere in 3D as one stroke of a real world-space width, with round joins and caps - a rope, an orbit, a trail that leaves the plane it started on.

public void DrawPolyline(ReadOnlySpan<Vector3> points, float width, Color color, bool closed = false)

Parameters

points ReadOnlySpan<Vector3>

The run, in world space, of any length.

width float

Stroke width in world units.

color Color

The stroke colour. Drawn solid, ignoring Alpha.

closed bool

Whether the last point joins back to the first.

Remarks

The stroke is measured on screen: every point is projected and the run is stroked in pixels, so it narrows with distance the way a rope does while BorderWidth stays a constant pixel width, and it faces the camera from every angle with no geometry behind it. Every fragment is depth-tested at its own depth along the run. A run of more than 64 points is split into pieces that share a point, and Dash restarts its pattern at each piece. A run that crosses the camera's near plane is not supported.

DrawRectangle(Vector2, Vector2, Color, float, float)

Submits a rectangle in the XY plane, the 2D case: a panel, a bar, a tile.

public void DrawRectangle(Vector2 center, Vector2 size, Color color, float cornerRadius = 0, float rotation = 0)

Parameters

center Vector2

Centre in the XY plane.

size Vector2

Width and height, in world units, or pixels with Screen on.

color Color

The outline colour, and the fill colour unless Color is set.

cornerRadius float

Optional corner rounding, in the same units as size. Limited to half the smaller side.

rotation float

Rotation in radians about the centre, counter-clockwise in the world and clockwise on screen.

DrawRectangle(Vector3, Vector3, Vector3, Vector2, Color, float)

Submits a rectangle lying in an arbitrary plane - a panel on a wall, a floor tile, a decal.

public void DrawRectangle(Vector3 center, Vector3 axisX, Vector3 axisY, Vector2 size, Color color, float cornerRadius = 0)

Parameters

center Vector3

World position of the rectangle's centre.

axisX Vector3

The plane's X axis. Normalized for you.

axisY Vector3

The plane's Y axis. Normalized for you.

size Vector2

Width along X and height along Y, in world units.

color Color

The outline colour, and the fill colour unless Color is set.

cornerRadius float

Optional corner rounding, in world units. Limited to half the smaller side, where the rectangle is a capsule or a circle.

DrawRing(Vector2, float, Color)

Submits an unfilled circle in the XY plane, the 2D case, stroked StrokeWidth pixels wide.

public void DrawRing(Vector2 center, float radius, Color color)

Parameters

center Vector2

Centre in the XY plane.

radius float

Radius in world units, or pixels with Screen on.

color Color

The ring colour.

DrawRing(Vector3, Vector3, float, Color)

Submits an unfilled circle lying flat in the plane a normal defines - a selection ring or a range indicator that does not tint what it encircles.

public void DrawRing(Vector3 center, Vector3 normal, float radius, Color color)

Parameters

center Vector3

World-space centre.

normal Vector3

Normal of the plane the ring lies in.

radius float

Radius in world units.

color Color

The ring colour.

Remarks

The ring is the shape, not the disc it encloses, so a Width glows on both sides of it. The stroke is StrokeWidth pixels wide; BorderWidth and Alpha do not apply.

DrawSector(Vector2, float, float, float, Color, float)

Submits a filled slice of a disc or ring in the XY plane, the 2D case of DrawSector(Vector3, Vector3, float, float, float, Color, float). Angles are counter-clockwise from the X axis.

public void DrawSector(Vector2 center, float radius, float startAngle, float sweepAngle, Color color, float innerRadius = 0)

Parameters

center Vector2

World-space centre the slice is cut from.

radius float

Outer radius in world units.

startAngle float

Where the slice starts, in radians from the X axis.

sweepAngle float

How far it extends, in radians. Positive is counter-clockwise, negative clockwise; a full turn or more is the whole ring or disc.

color Color

The outline colour, and the fill colour unless Color is set.

innerRadius float

Radius of the hole, in world units; 0 (the default) cuts from the centre.

DrawSector(Vector3, Vector3, float, float, float, Color, float)

Submits a filled slice of a disc, cut by two radial edges, lying flat in the plane a normal defines: a pie wedge, a field-of-view cone, a cooldown sweep. With an inner radius it is a slice of a ring instead - a donut chart segment, a radial progress bar with square ends.

public void DrawSector(Vector3 center, Vector3 normal, float radius, float startAngle, float sweepAngle, Color color, float innerRadius = 0)

Parameters

center Vector3

World-space centre the slice is cut from.

normal Vector3

Normal of the plane the slice lies in.

radius float

Outer radius in world units.

startAngle float

Where the slice starts, in radians. See the remarks for where 0 is.

sweepAngle float

How far it extends, in radians. Positive is counter-clockwise, negative clockwise; a full turn or more is the whole ring or disc.

color Color

The outline colour, and the fill colour unless Color is set.

innerRadius float

Radius of the hole, in world units; 0 (the default) cuts from the centre.

Remarks

Angles increase counter-clockwise as seen from the side the normal points to. Zero lies along the plane's X axis, which is world X for a slice lying on the ground (normal up) and for one standing in the XY plane (normal +Z); add an offset to the start angle to turn it.

DrawSolidCircle(Vector2, float, Color)

Submits a circle in the XY plane, the 2D case.

public void DrawSolidCircle(Vector2 center, float radius, Color color)

Parameters

center Vector2

World-space centre.

radius float

Radius in world units.

color Color

The outline colour, and the fill colour unless Color is set.

DrawSolidPolygon(ReadOnlySpan<Vector2>, Vector2, float, Color, float)

Submits a convex polygon lying in the XY plane, the 2D case.

public void DrawSolidPolygon(ReadOnlySpan<Vector2> vertices, Vector2 position, float rotation, Color color, float radius = 0)

Parameters

vertices ReadOnlySpan<Vector2>

The corners in local space, counter-clockwise.

position Vector2

World position of the shape's local origin.

rotation float

Rotation in radians about the Z axis.

color Color

The outline colour, and the fill colour unless Color is set.

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

No vertices were given.

DrawSolidPolygon(ReadOnlySpan<Vector2>, Vector3, Quaternion, Color, float)

Submits a convex polygon in the plane a rotation puts the XY plane in.

public void DrawSolidPolygon(ReadOnlySpan<Vector2> vertices, Vector3 position, Quaternion rotation, Color color, float radius = 0)

Parameters

vertices ReadOnlySpan<Vector2>

The corners in local space, counter-clockwise.

position Vector3

World position of the shape's local origin.

rotation Quaternion

Orientation of the shape's plane.

color Color

The outline colour, and the fill colour unless Color is set.

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

No vertices were given.

DrawSolidPolygon(ReadOnlySpan<Vector2>, Vector3, Vector3, Vector3, Color, float, float)

Submits a convex polygon lying in an arbitrary plane in 3D.

public void DrawSolidPolygon(ReadOnlySpan<Vector2> vertices, Vector3 position, Vector3 axisX, Vector3 axisY, Color color, float radius = 0, float scale = 1)

Parameters

vertices ReadOnlySpan<Vector2>

The corners in the plane's local space, counter-clockwise.

position Vector3

World position of the shape's local origin.

axisX Vector3

The plane's X axis. Normalized for you.

axisY Vector3

The plane's Y axis. Normalized for you.

color Color

The outline colour, and the fill colour unless Color is set.

radius float

Optional rounding radius around the polygon, in world units.

scale float

Uniform scale applied to the whole shape, radius included. Zero or less draws nothing.

Exceptions

ArgumentException

No vertices were given.

DrawWireBox(Vector3, Vector3, float, Color)

Submits the twelve edges of an axis-aligned box as thick lines - a bounds or selection volume whose edges keep their width at any distance.

public void DrawWireBox(Vector3 center, Vector3 size, float width, Color color)

Parameters

center Vector3

World-space centre of the box.

size Vector3

Full extent along each axis, in world units.

width float

Edge width in world units.

color Color

The edge colour.

FillWith(Texture, Vector2?, Vector2?, TextureAddressMode)

Fills the batch's textured shapes with a texture: the common case of FillSource.

public ComputeTextureColor FillWith(Texture texture, Vector2? scale = null, Vector2? offset = null, TextureAddressMode addressMode = TextureAddressMode.Clamp)

Parameters

texture Texture

The texture to sample, or a render target another camera draws into.

scale Vector2?

How many times the texture repeats across the shape's bounding box; the default 1 fits it once.

offset Vector2?

Where the texture starts, in texture units; animate it for a scrolling fill.

addressMode TextureAddressMode

What shows beyond the texture's edges - beyond the bounding box, or past one repeat. The default Stride.Graphics.TextureAddressMode.Clamp extends the edge pixels, right for a picture; Stride.Graphics.TextureAddressMode.Wrap tiles, for stripes and patterns.

Returns

ComputeTextureColor

The node it installed, so its properties can be changed later.

PickAll(Vector2, float)

Every tagged shape under a screen position, as of the frame last drawn, front to back: nearest depth first, and at equal depth the shape drawn last first.

public IReadOnlyList<ShapeHit> PickAll(Vector2 screenPosition, float slackPixels = 0)

Parameters

screenPosition Vector2

The position, normalised (0,0) top left to (1,1) bottom right.

slackPixels float

How far outside the outline, in pixels, still counts as a hit.

Returns

IReadOnlyList<ShapeHit>

TryPick(Ray, out ShapeHit, float)

The topmost tagged shape a world ray hits, for a caller with a ray of its own. Screen shapes and space strokes are measured on the screen and have no answer for a ray; use the screen position overload for them.

public bool TryPick(Ray ray, out ShapeHit hit, float slackPixels = 0)

Parameters

ray Ray

The ray, in world units.

hit ShapeHit

The shape found.

slackPixels float

How far outside the outline, in pixels, still counts as a hit.

Returns

bool

TryPick(Vector2, out ShapeHit, float)

The topmost tagged shape under a screen position, as of the frame last drawn: the nearest to the camera, and at equal depth the one drawn last. A screen shape is over everything.

public bool TryPick(Vector2 screenPosition, out ShapeHit hit, float slackPixels = 0)

Parameters

screenPosition Vector2

The position, normalised (0,0) top left to (1,1) bottom right - Input.MousePosition as it comes.

hit ShapeHit

The shape found.

slackPixels float

How far outside the outline, in pixels, still counts as a hit: a few pixels make a thin line or ring clickable. The border already counts as the shape.

Returns

bool

Whether any tagged shape is under the position.

Remarks

A pick sees what the batch drew and nothing else: a shape behind scene geometry still picks, because the batch has no depth buffer to consult, and a shape with no tag never does. A dashed outline picks as if solid.

WorldPerPixel(Vector3)

World units per on-screen pixel at a point, as of the frame last drawn: the figure the shader uses for pixel-measured widths and radii, in scaled pixels when AutoScale is on. Returns 0 until the batch has been drawn once.

public float WorldPerPixel(Vector3 point)

Parameters

point Vector3

The point in the world.

Returns

float