Skip to content

Instantly share code, notes, and snippets.

@mattkrins
Last active March 21, 2017 10:58
Show Gist options
  • Save mattkrins/463df308c8e0db68f1fb548f537f905c to your computer and use it in GitHub Desktop.
Save mattkrins/463df308c8e0db68f1fb548f537f905c to your computer and use it in GitHub Desktop.
A simple but practical Garry's Mod draw helper function, particularly useful with 3D2D rendering operations.
function draw.ContainerBox( r, x, y, w, h, c, p )
draw.RoundedBox( r or 0, x or 0, y or 0, w or 0, h or 0, c or color_white )
if p then p(x or 0, y or 0, w or 0, h or 0) end
end
@mattkrins
Copy link
Author

Example:

draw.ContainerBox( 0, 0, 0, 200, 200, Color( 0, 0, 0, 255 ), function(x, y, w, h)
	draw.ContainerBox( 4, x+5, y+5, w-10, 22, Color( 50, 50, 50, 255 ), function(x, y, w, h)
		draw.SimpleText( "TEST", "DermaDefault", x+(w/2), y+(h/2), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
	end)
	draw.ContainerBox( 0, x+(w/2-(50/2)), y+(h/2-(50/2)), 50, 50, Color( 255, 124, 102, 255 ))
end)

Result:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment