surface.SetTextColor

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

Contents

Description

Set the color of any future text 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

Arguments

number b

The blue value of color

Arguments

number a=255

The alpha value of color

Examples

Example

Draws 'Hello World', in white, near the top left of the screen.

hook.Add( "HUDPaint", "HUDPaint_DrawABox", function()
	surface.SetDrawColor( 0, 0, 0, 128 ) -- Set color for background
	surface.DrawRect( 100, 100, 128, 20 ) -- Draw background

	surface.SetTextColor( 255, 255, 255 ) -- Set text color
	surface.SetTextPos( 136, 104 ) -- Set text position, top left corner
	surface.SetFont( "Default" ) -- Set the font
	surface.DrawText( "Hello World" ) -- Draw the text
end )


Personal tools
Navigation