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, Fill, Glow, Dash, Gradient, Opacity, DepthFade, Textured and Screen 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 figure comes from DisplayScale, shared with everything else in the toolkit that draws in pixels, and is re-read when the window moves to another monitor. Turn it off to get exactly the pixels asked for - a screenshot at a known size, or a game applying its own UI-scale setting through Override and nothing else should compound it. World-unit sizes are never affected either way.

BorderWidth

Outline width in on-screen pixels, constant at any zoom or distance. The Box2D testbed uses 3; set 0 for a borderless fill. Captured by each draw call as it is made.

public float BorderWidth { get; set; }

Property Value

float

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 shapes 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

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.

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 the testbed way, and its intensity. 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 Corner(ScreenCorner) 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

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 Corner(ScreenCorner); nothing is clipped to it.

public RectangleF? Viewport { get; set; }

Property Value

RectangleF?

Methods

Corner(ScreenCorner)

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

public Vector2 Corner(ScreenCorner corner)

Parameters

corner ScreenCorner

Which corner.

Returns

Vector2

The corner, 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; the fill derives from it and Alpha.

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; the fill derives from it and Alpha.

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.

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.

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, at most 8.

position Vector3

World position of the shape's centre.

color Color

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

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

Fewer than 1 or more than 8 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; the fill derives from it and Alpha.

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; the fill derives from it and Alpha.

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(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 BorderWidth 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 only under an Opacity below one, as a slightly brighter dot. 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. A run of more than 64 points is split into pieces that share a point; each piece depth-tests as its nearest point, and Dash restarts its pattern at each piece. A run that crosses the camera's near plane is not supported.

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; the fill derives from it and Alpha.

cornerRadius float

Optional corner rounding, in world units.

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. Alpha does 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; the fill derives from it and Alpha.

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; the fill derives from it and Alpha.

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; the fill derives from it and Alpha.

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, at most 8.

position Vector2

World position of the shape's local origin.

rotation float

Rotation in radians about the Z axis.

color Color

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

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

Fewer than 1 or more than 8 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, at most 8.

position Vector3

World position of the shape's local origin.

rotation Quaternion

Orientation of the shape's plane.

color Color

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

radius float

Optional rounding radius around the polygon, in world units.

Exceptions

ArgumentException

Fewer than 1 or more than 8 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, at most 8.

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; the fill derives from it and Alpha.

radius float

Optional rounding radius around the polygon, in world units.

scale float

Uniform scale applied to the whole shape, radius included.

Exceptions

ArgumentException

Fewer than 1 or more than 8 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 Clamp extends the edge pixels, right for a picture; 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)

How much of the world one on-screen pixel covers at a point, as the last drawn frame saw it - the same figure the shader uses for a pixel-measured width or radius, in the display's scaled pixels when AutoScale is on. What a line needs to stop short of a pixel-radius ring by the ring's radius, whatever the distance; 0 until the batch has been drawn once.

public float WorldPerPixel(Vector3 point)

Parameters

point Vector3

The point in the world.

Returns

float