s&box docs

public static abstract sealed class Sandbox.UI.Panel.Draw

To be used inside `Sandbox.UI.Panel.OnDraw` to add custom shapes, textures and text to a panel. These draw calls will be batched together with the panel's CSS-styled content for efficient rendering. public override void OnDraw() { Draw.Rect( new Rect( 0, 0, 100, 100 ), Color.Red, cornerRadius: 8 ); Draw.Text( "Hello", new Rect( 10, 10, 80, 20 ), 14, Color.White ); }

Methods

Showing 7 methods

public static void Circle(Vector2 center, float radius, Color color)

Draws a filled circle.

Parameters

  • center: Center position in panel-local coordinates.
  • radius: Circle radius in pixels.
  • color: Fill color.

public static void Outline(Sandbox.Rect rect, Color color, float width, float cornerRadius = 0, float offset = 0)

Draws an outline (stroke) around a rectangle.

Parameters

  • rect: The rectangle to outline, in panel-local coordinates.
  • color: Outline color.
  • width: Outline thickness in pixels.
  • cornerRadius: Corner radius to match rounded rectangles. Default: 0
  • offset: Outline offset. Positive values push the outline outward, negative values pull it inward. Default: 0

public static void Shadow(Sandbox.Rect rect, Color color, float blur = 0, float spread = 0, Vector2 offset = null, float cornerRadius = 0, bool inset = False)

Draws a box shadow (drop shadow or inset shadow).

Parameters

  • rect: The rectangle to cast the shadow from, in panel-local coordinates.
  • color: Shadow color.
  • blur: Blur radius in pixels. Higher values produce softer shadows. Default: 0
  • spread: Spread distance in pixels. Positive values expand the shadow, negative values shrink it. Default: 0
  • offset: Shadow offset from the rectangle position. Default: null
  • cornerRadius: Corner radius to match rounded rectangles. Default: 0
  • inset: If true, draws an inner shadow instead of a drop shadow. Default: False

public static void Text(string text, Sandbox.Rect rect, float size, Color color, Sandbox.TextFlag flags = 33)

Draws a text string within the given rectangle.

Parameters

  • text: The text to render.
  • rect: Bounding rectangle for text layout, in panel-local coordinates.
  • size: Font size in pixels.
  • color: Text color.
  • flags: Text alignment and layout flags. Defaults to `Sandbox.TextFlag.LeftTop`. Default: 33

public static void Texture(Sandbox.Texture texture, Sandbox.Rect rect, System.Nullable`1<Color> tint = null)

Parameters

  • tint: Default: null

Metadata

FieldValue
Namespaceglobal
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.UI.Panel.Draw

On this page