Drawclass

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 ); }

objectDraw
Namespace
global
Assembly
Sandbox.Engine
Declaration
public static abstract sealed class Sandbox.UI.Panel.Draw

Methods7

Showing 7 methods

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

Draws a filled circle.

ParameterTypeDescription
centerVector2Center position in panel-local coordinates.
radiusfloatCircle radius in pixels.
colorColorFill color.
Returns:void

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

Draws an outline (stroke) around a rectangle.

ParameterTypeDescription
rectRectThe rectangle to outline, in panel-local coordinates.
colorColorOutline color.
widthfloatOutline thickness in pixels.
cornerRadius = 0floatCorner radius to match rounded rectangles.
offset = 0floatOutline offset. Positive values push the outline outward, negative values pull it inward.
Returns:void

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

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

ParameterTypeDescription
rectRectThe rectangle to cast the shadow from, in panel-local coordinates.
colorColorShadow color.
blur = 0floatBlur radius in pixels. Higher values produce softer shadows.
spread = 0floatSpread distance in pixels. Positive values expand the shadow, negative values shrink it.
offset = nullVector2Shadow offset from the rectangle position.
cornerRadius = 0floatCorner radius to match rounded rectangles.
inset = FalseboolIf true, draws an inner shadow instead of a drop shadow.
Returns:void

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

Draws a text string within the given rectangle.

ParameterTypeDescription
textstringThe text to render.
rectRectBounding rectangle for text layout, in panel-local coordinates.
sizefloatFont size in pixels.
colorColorText color.
flags = 33TextFlagText alignment and layout flags. Defaults to `Sandbox.TextFlag.LeftTop`.
font = RobotostringFont family name. Defaults to "Roboto".
Returns:void

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

ParameterTypeDescription
textureTexture
rectRect
tint = nullNullable<Color>
Returns:void

On this page