Garry's Mod Wiki

surface.SetDrawColor

surface.SetDrawColor( number r, number g, number b, number a = 255 )

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. Using a color structure is not recommended to be created procedurally.

Providing a Color structure is slower than providing four numbers. You may use Color:Unpack for this.
The alpha value may not work properly if you're using a material without $vertexalpha.
Due to post processing and gamma correction the color you set with this function may appear differently when rendered. This problem does not occur on materials drawn with surface.DrawTexturedRect.

Arguments

1 number r
The red value of color, or a Color.
2 number g
The green value of color. Unused if a Color was given.
3 number b
The blue value of color. Unused if a Color was given.
4 number a = 255
The alpha value of color. Unused if a Color was given.

Example

Draws a 512x512 textured rectangle with the wireframe material.

local myMaterial = Material( "models/wireframe" ) -- Calling Material() every frame is quite expensive hook.Add( "HUDPaint", "example_hook", function() surface.SetDrawColor( 255, 0, 0 ) -- Set the color to red surface.SetMaterial( myMaterial ) -- If you use Material, cache it! surface.DrawTexturedRect( 0, 0, 512, 512 ) end )

Page Links


Special Pages


Wikis

?

Render Time: 307ms

DB GetPage 31
Generate Html 35
SaveChanges (1) 222
Render Body 0
Render Sidebar 15