surface.DrawOutlinedRect

From Garry's Mod
Jump to: navigation, search
 surface.DrawOutlinedRect( )

Contents

Description

Draws a hollow box with a border width of 1 px.

NOTE

This is a rendering function that requires a 2D rendering context.
This means that it will only work in hooks with a 2D rendering context.

Arguments

number x

The start x integer coordinate.

Arguments

number y

The start y integer coordinate.

Arguments

number w

The integer width.

Arguments

number h

The integer height.

Examples

Example

Draws a 100x100 outlined rectangle in top left corner.

surface.SetDrawColor( Color( 255, 255, 255, 255 ) )
surface.DrawOutlinedRect( 0, 0, 100, 100 )


Examples

Example

A convenience function to draw an outlined rect with given color and thickness

function draw.OutlinedBox( x, y, w, h, thickness, clr )
	surface.SetDrawColor( clr )
	for i=0, thickness - 1 do
		surface.DrawOutlinedRect( x + i, y + i, w - i * 2, h - i * 2 )
	end
end

// Usage
hook.Add( "HUDPaint", "OutlinedRectExample", function()
	draw.OutlinedBox( 0, 0, 100, 100, 2, Color( 255, 255, 255 ) )
end )


Personal tools
Navigation