Garry's Mod Wiki

Revision Difference

surface.SetDrawColor#527698

<function name="SetDrawColor" parent="surface" type="libraryfunc"> <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 <page>Color</page>. Using a color structure is not recommended to be created procedurally. <note>Providing a <page>Color</page> structure is slower than providing four numbers. You may use <page>Color:Unpack</page> for this.</note></description> <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 <page>Color</page>. Using a color structure is not recommended to be created procedurally. <note>Providing a <page>Color</page> structure is slower than providing four numbers. You may use <page>Color:Unpack</page> for this.</note> <note>The alpha value may not work properly if you're using a material without `$vertexalpha`.</note> </description> <realm>Client and Menu</realm> <args> <arg name="r" type="number">The red value of color, or a <page>Color</page>.</arg> <arg name="g" type="number">The green value of color. Unused if a <page>Color</page> was given.</arg> <arg name="b" type="number">The blue value of color. Unused if a <page>Color</page> was given.</arg> <arg name="a" type="number" default="255">The alpha value of color. Unused if a <page>Color</page> was given.</arg> </args> </function> <example> <description>Draws a 512x512 textured rectangle with the wireframe material</description> <code> local ourMat = 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( ourMat ) -- If you use Material, cache it! surface.DrawTexturedRect( 0, 0, 512, 512 ) end ) </code> </example> </example>