# Sandbox.Painter

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.

- Kind: struct
- Namespace: `Sandbox`
- Assembly: `Sandbox.Engine`
- Modifiers: sealed

## Properties

- [`BlendMode`](/api/Sandbox.Painter/BlendMode): Blend mode for subsequent draws. Defaults to BlendMode.Normal.
- [`Bounds`](/api/Sandbox.Painter/Bounds): The destination bounds in drawing coordinates. Panel painters start at (0, 0).
- [`Fill`](/api/Sandbox.Painter/Fill): Fill for closed shapes. Defaults to Fill.None.
- [`Opacity`](/api/Sandbox.Painter/Opacity): Alpha multiplier for each draw, clamped to [0, 1]. Defaults to 1.
- [`Stroke`](/api/Sandbox.Painter/Stroke): Stroke for shapes and lines. Defaults to Stroke.None. Open paths always use centered alignment.
- [`TextStyle`](/api/Sandbox.Painter/TextStyle): Style used by Text and MeasureText. Defaults to TextStyle.Default.
- [`Transform`](/api/Sandbox.Painter/Transform): 2D affine transform applied before the destination transform. Defaults to identity.

## Methods

- [`Arc`](/api/Sandbox.Painter/Arc): Draws an arc using the current [Sandbox.Painter.Stroke](/api/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.
- [`Arrow`](/api/Sandbox.Painter/Arrow): Draws a shafted arrow as one polygon using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill) and [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke). All dimensions are in drawing pixels. Zero-length arrows or nonpositive shaft/head sizes draw nothing.
- [`Begin`](/api/Sandbox.Painter/Begin): Starts painting a render-target texture. Dispose the painter to submit its drawing. Existing pixels are preserved unless Clear is called.
- [`BeginLayer`](/api/Sandbox.Painter/BeginLayer)
- [`Bezier`](/api/Sandbox.Painter/Bezier): Draws a quadratic Bezier using [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke).
- [`Capsule`](/api/Sandbox.Painter/Capsule): 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.
- [`Circle`](/api/Sandbox.Painter/Circle): Draws a circle using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill) and the current [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke). Radius and width are in drawing pixels.
- [`Clear`](/api/Sandbox.Painter/Clear): Clears the destination, ignoring drawing state. Supported by texture and command-list painters, outside layers.
- [`Clip`](/api/Sandbox.Painter/Clip): 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.
- [`Crescent`](/api/Sandbox.Painter/Crescent): 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.
- [`Cross`](/api/Sandbox.Painter/Cross): 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.
- [`Dispose`](/api/Sandbox.Painter/Dispose): Submits a destination-owned recording. Copies may be disposed more than once. Panel-supplied painters do not own their recording.
- [`FilterBackdrop`](/api/Sandbox.Painter/FilterBackdrop): Filter pixels already drawn behind a rectangle. Captures the current transform, clip, opacity and blend mode.
- [`Heart`](/api/Sandbox.Painter/Heart): 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.
- [`Line`](/api/Sandbox.Painter/Line)
- [`LineSmooth`](/api/Sandbox.Painter/LineSmooth)
- [`MeasureText`](/api/Sandbox.Painter/MeasureText): Measures text with the current TextStyle, including glyph overhang, in the same coordinates as Painter.Text. maxSize supplies the same layout bounds as a drawing rectangle; default uses Painter.Text's unconstrained bounds. The result includes ScaleToScreen but excludes Painter.Transform, clipping and opacity. Empty text returns zero. Prepares cached layout without recording a draw or allocating a bitmap or GPU texture. A later draw reuses the layout.
- [`Outline`](/api/Sandbox.Painter/Outline): Draws an outline using [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke). At zero offset, its inner edge follows the rectangle. Positive offsets push the outline outward; negative offsets pull it inward. All dimensions are in drawing pixels.
- [`Pie`](/api/Sandbox.Painter/Pie): Draws a pie sector using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill) and the current [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke). Angles are clockwise degrees from right; negative sweeps are supported. A full sweep draws a circle without radial seams.
- [`Polygon`](/api/Sandbox.Painter/Polygon)
- [`Quad`](/api/Sandbox.Painter/Quad): Draws a quad using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill) and the current [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke). Vertices follow the perimeter in drawing pixels.
- [`Rect`](/api/Sandbox.Painter/Rect): Draws a filled rectangle with independent inside border widths and colors, ordered left, top, right, bottom. Uses Fill for the background and Stroke.Style for the border, with CSS corner joins and dash/dot spacing. Stroke.Width, Stroke.Fill, Alignment, Cap and Join do not affect these explicit borders. Border widths must be finite and non-negative. Corners follow the same rules as Rect.
- [`RectShadow`](/api/Sandbox.Painter/RectShadow)
- [`Ring`](/api/Sandbox.Painter/Ring): Draws the band between inner and outer radii using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill), with the current [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke) on both circular edges. Inside/outside alignment is relative to the band. Radii are in drawing pixels. A zero inner radius draws a circle. Negative, non-finite, equal or reversed radii draw nothing.
- [`Rotate`](/api/Sandbox.Painter/Rotate): Rotates the drawing axes clockwise in degrees around their current origin.
- [`Scale`](/api/Sandbox.Painter/Scale): Scales both drawing axes around their current origin, including stroke widths and text.
- [`Scope`](/api/Sandbox.Painter/Scope): Saves drawing state until the returned scope is disposed.
- [`Star`](/api/Sandbox.Painter/Star): 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.
- [`Text`](/api/Sandbox.Painter/Text): Draws text with the current TextStyle, opacity, transform and clip.
- [`Texture`](/api/Sandbox.Painter/Texture)
- [`Tick`](/api/Sandbox.Painter/Tick): 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.
- [`Translate`](/api/Sandbox.Painter/Translate): Moves the drawing origin along its current axes.
- [`Triangle`](/api/Sandbox.Painter/Triangle): Draws a triangle using [Sandbox.Painter.Fill](/api/Sandbox.Painter/Fill) and the current [Sandbox.Painter.Stroke](/api/Sandbox.Painter/Stroke), in drawing pixels.
