Garry's Mod Wiki

draw

The draw library's purpose is to simplify the usage of the surface library.

Methods

draw.DrawText( string text, string font = "DermaDefault", number x = 0, number y = 0, table color = Color( 255, 255, 255, 255 ), number xAlign = TEXT_ALIGN_LEFT )
Simple draw text at position, but this will expand newlines and tabs. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks. See also MarkupObject for limited width and markup support.
Returns the height of the specified font in pixels. This is equivalent to the height of the character W. See surface. GetTextSize. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
draw.NoTexture()
Sets drawing texture to a default white texture (vgui/white) via surface. SetMaterial. Useful for resetting the drawing texture. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color )
Draws a rounded rectangle. If you do not define a cornerRadius, surface. DrawRect will be used instead for performance. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
draw.RoundedBoxEx( number cornerRadius, number x, number y, number width, number height, table color, boolean roundTopLeft = false, boolean roundTopRight = false, boolean roundBottomLeft = false, boolean roundBottomRight = false )
Draws a rounded rectangle. This function also lets you specify which corners are drawn rounded. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
number, number draw.SimpleText( string text, string font = "DermaDefault", number x = 0, number y = 0, table color = Color( 255, 255, 255, 255 ), number xAlign = TEXT_ALIGN_LEFT, number yAlign = TEXT_ALIGN_TOP )
Draws text on the screen. This function does not handle newlines properly. See draw. DrawText for a function that does. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
number, number draw.SimpleTextOutlined( string Text, string font = "DermaDefault", number x = 0, number y = 0, table color = Color( 255, 255, 255, 255 ), number xAlign = TEXT_ALIGN_LEFT, number yAlign = TEXT_ALIGN_TOP, number outlinewidth, table outlinecolor = Color( 255, 255, 255, 255 ) )
Creates a simple line of text that is outlined. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
number, number draw.Text( table textdata )
Works like draw. SimpleText but uses a table structure instead. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
number, number draw.TextShadow( table textdata, number distance, number alpha = 200 )
Works like draw. Text, but draws the text as a shadow. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
draw.TexturedQuad( table texturedata )
Draws a texture with a table structure. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
number, number draw.WordBox( number bordersize, number x, number y, string text, string font, table boxcolor, table textcolor, number xalign = TEXT_ALIGN_LEFT, number yalign = TEXT_ALIGN_TOP )
Draws a rounded box with text in it. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.