surface.SetDrawColor

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

Contents

Description

Set the color of any future shapes to be drawn, can be set by either using r, g, b, a as separate values or by a Color structure. Using a color structure is not recommended to be created procedurally.

Arguments

number r

The red value of color, or a Color structure.

Arguments

number g

The green value of color. Unused if a Color structure was given.

Arguments

number b

The blue value of color. Unused if a Color structure was given.

Arguments

number a=255

The alpha value of color. Unused if a Color structure was given.

Examples

Example

Draws a 512x512 textured rectangle with the wireframe material

local ourMat = Material( "models/wireframe" ) -- Calling Material() every frame is quite expensive

hook.Add( "HUDPaint", "example_hook", function()
	surface.SetDrawColor( 255, 0, 0, 255 ) -- Set the color to red
	surface.SetMaterial( ourMat ) -- If you use Material, cache it!
	surface.DrawTexturedRect( 0, 0, 512, 512 )
end )


Personal tools
Navigation