Painterclass
Records 2D drawing commands. Obtained from Painter.Begin() or a panel's OnDraw callback. Copies share drawing state. Dispose a destination-owned painter to submit; panel-supplied painters remain owned by the panel.
Methods48
Showing 48 methods
public void Arc(Vector2 center, float radius, float startAngle, float sweepAngle)
Draws an arc using the current `Sandbox.Painter.Stroke` with angles in clockwise degrees from right. Negative sweeps run counterclockwise. Radius measures to the centerline in drawing pixels. Sweeps of at least 360 degrees form a closed ring.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| radius | float | — |
| startAngle | float | — |
| sweepAngle | float | — |
void—public void Arrow(Vector2 from, Vector2 to, float width = 4, float headSize = 16)
Draws a shafted arrow as one polygon using `Sandbox.Painter.Fill` and `Sandbox.Painter.Stroke`. All dimensions are in drawing pixels. Zero-length arrows or nonpositive shaft/head sizes draw nothing.
| Parameter | Type | Description |
|---|---|---|
| from | Vector2 | Center of the shaft's starting edge. |
| to | Vector2 | Arrow tip. |
| width = 4 | float | Shaft width. |
| headSize = 16 | float | Head length and width. Length is limited to the arrow's length; width is at least the shaft width. |
void—public Sandbox.Painter.LayerScope BeginLayer(Sandbox.Rect bounds, float opacity = 1, System.Nullable`1<Sandbox.Painter.Filter> filter = null, System.Nullable`1<Sandbox.Painter.Mask> mask = null)
| Parameter | Type | Description |
|---|---|---|
| bounds | Rect | — |
| opacity = 1 | float | — |
| filter = null | Nullable<Filter> | — |
| mask = null | Nullable<Mask> | — |
public void Capsule(Vector2 from, Vector2 to, float fromRadius, float toRadius)
Draws the convex hull of two discs using Fill and Stroke. Endpoint radii are in drawing pixels. Equal radii form a capsule; unequal radii taper along common tangents. A contained disc reduces to the larger circle.
| Parameter | Type | Description |
|---|---|---|
| from | Vector2 | — |
| to | Vector2 | — |
| fromRadius | float | — |
| toRadius | float | — |
void—public void Clear(Color color)
Clears the destination, ignoring drawing state. Supported by texture and command-list painters, outside layers.
| Parameter | Type | Description |
|---|---|---|
| color | Color | — |
void—public void Clip(Sandbox.Rect rect, Sandbox.Painter.CornerRadii corners = null)
Intersects subsequent drawing with a rectangle, optionally rounded like Painter.Rect. Captures the current Transform; later transform changes do not move this clip. Nested clips intersect with each other and the panel's CSS clip. Scope() restores the previous clip. Empty rectangles or a collapsed transform clip all drawing.
| Parameter | Type | Description |
|---|---|---|
| rect | Rect | — |
| corners = null | CornerRadii | — |
void—public void Crescent(Vector2 center, float radius, float cutoutRadius, Vector2 cutoutOffset)
Draws a circle minus an offset circular cutout using Fill and Stroke. Dimensions and offset are in drawing pixels. Moving the cutout changes the moon's phase and direction. Disjoint circles leave a disc; a covering cutout draws nothing.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| radius | float | — |
| cutoutRadius | float | — |
| cutoutOffset | Vector2 | — |
void—public void Cross(Vector2 center, float width, float length)
Draws a plus-shaped cross as one contour using Fill and Stroke, without overlapping bars. Width is the thickness of each bar; length is the full tip-to-tip span on both axes, in drawing pixels. Nonpositive, non-finite dimensions or a width greater than length draw nothing.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| width | float | — |
| length | float | — |
void—public void Dispose()
Submits a destination-owned recording. Copies may be disposed more than once. Panel-supplied painters do not own their recording.
void—public void FilterBackdrop(Sandbox.Rect rect, Sandbox.Painter.Filter filter, Sandbox.Painter.CornerRadii corners = null)
Filter pixels already drawn behind a rectangle. Captures the current transform, clip, opacity and blend mode.
| Parameter | Type | Description |
|---|---|---|
| rect | Rect | — |
| filter | Filter | — |
| corners = null | CornerRadii | — |
void—public void Heart(Vector2 center, float size)
Draws a heart with two round lobes and a pointed base, using Fill and Stroke. Size is the full width in drawing pixels; its proportions are fixed and its bounds are centered at center.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| size | float | — |
void—public void LineSmooth(System.ReadOnlySpan`1<Vector2> points)
| Parameter | Type | Description |
|---|---|---|
| points | ReadOnlySpan<Vector2> | — |
void—public void Pie(Vector2 center, float radius, float startAngle, float sweepAngle)
Draws a pie sector using `Sandbox.Painter.Fill` and the current `Sandbox.Painter.Stroke`. Angles are clockwise degrees from right; negative sweeps are supported. A full sweep draws a circle without radial seams.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| radius | float | — |
| startAngle | float | — |
| sweepAngle | float | — |
void—public void Polygon(System.ReadOnlySpan`1<Vector2> points)
| Parameter | Type | Description |
|---|---|---|
| points | ReadOnlySpan<Vector2> | — |
void—public void Quad(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
Draws a quad using `Sandbox.Painter.Fill` and the current `Sandbox.Painter.Stroke`. Vertices follow the perimeter in drawing pixels.
| Parameter | Type | Description |
|---|---|---|
| a | Vector2 | — |
| b | Vector2 | — |
| c | Vector2 | — |
| d | Vector2 | — |
void—public void RectShadow(Sandbox.Rect rect, Sandbox.Painter.CornerRadii corners = null, System.Nullable`1<Color> color = null, float blur = 0, float spread = 0, Vector2 offset = null, bool inset = False)
| Parameter | Type | Description |
|---|---|---|
| rect | Rect | — |
| corners = null | CornerRadii | — |
| color = null | Nullable<Color> | — |
| blur = 0 | float | — |
| spread = 0 | float | — |
| offset = null | Vector2 | — |
| inset = False | bool | — |
void—public void Rotate(float degrees)
Rotates the drawing axes clockwise in degrees around their current origin.
| Parameter | Type | Description |
|---|---|---|
| degrees | float | — |
void—public Sandbox.Painter.StateScope Scope()
Saves drawing state until the returned scope is disposed.
public void Star(Vector2 center, float bodyRadius, float spikeLength, int points = 5, float rotation = -90)
Draws a star using Fill and Stroke. Body radius measures to the valleys; spike length extends beyond it to the tips, in drawing pixels. Rotation is clockwise degrees from right. At least three points and a positive body radius are required. Zero spike length draws a regular polygon.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| bodyRadius | float | — |
| spikeLength | float | — |
| points = 5 | int | — |
| rotation = -90 | float | — |
void—public void Text(string text, Sandbox.Rect rect)
Draws text with the current TextStyle, opacity, transform and clip.
| Parameter | Type | Description |
|---|---|---|
| text | string | — |
| rect | Rect | — |
void—public void Texture(Sandbox.Texture texture, Sandbox.Rect rect, System.Nullable`1<Color> tint = null)
| Parameter | Type | Description |
|---|---|---|
| texture | Texture | — |
| rect | Rect | — |
| tint = null | Nullable<Color> | — |
void—public void Tick(Vector2 center, float width, float length)
Draws a check mark as one filled contour using Fill and Stroke. Width is the arm thickness; length is the horizontal span of its centerline in drawing pixels. The long arm rises to the right. Nonpositive, non-finite dimensions or a width greater than half the length draw nothing.
| Parameter | Type | Description |
|---|---|---|
| center | Vector2 | — |
| width | float | — |
| length | float | — |
void—No results match this filter.
Properties7
Showing 7 properties
public Sandbox.BlendMode Sandbox.Painter.BlendMode { get; set; }
Blend mode for subsequent draws. Defaults to BlendMode.Normal.
public Sandbox.Rect Sandbox.Painter.Bounds { get; set; }
The destination bounds in drawing coordinates. Panel painters start at (0, 0).
public Sandbox.Fill Sandbox.Painter.Fill { get; set; }
Fill for closed shapes. Defaults to Fill.None.
public float Sandbox.Painter.Opacity { get; set; }
Alpha multiplier for each draw, clamped to [0, 1]. Defaults to 1.
float—public Sandbox.Stroke Sandbox.Painter.Stroke { get; set; }
Stroke for shapes and lines. Defaults to Stroke.None. Open paths always use centered alignment.
No results match this filter.