Revision Difference
surface.SetDrawColor#561277
<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>⤶
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>.
⤶
<note>The alpha value may not work properly if you're using a material without `$vertexalpha`.</note>
<note>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 <page>surface.DrawTexturedRect</page>.</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>
<arg name="r" type="number">The red value of color.</arg>
<arg name="g" type="number">The green value of color.</arg>
<arg name="b" type="number">The blue value of color.</arg>
<arg name="a" type="number" default="255">The alpha value of color.</arg>
</args>⤶
<args name="Use color object">⤶
<arg name="color" type="table">A <page>Color</page> object/table to read the color from. This is slower than providing four numbers. You could use <page>Color:Unpack</page> to address this. You should also cache your color objects if you wish to use them, for performance reasons.</arg>⤶
</args>
</function>
<example>
<description>Draws a 512x512 textured rectangle with the wireframe material.</description>
<code>
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 )
</code>
</example>