Garry's Mod Wiki

Revision Difference

Panel:SetFGColor#511035

<function name="SetFGColor" parent="Panel" type="classfunc">⤶ <description>⤶ Sets the foreground color of a panel.⤶ ⤶ For a <page>Label</page> or <page>RichText</page>, this is the color of its text.⤶ ⤶ This function calls <page>Panel:SetFGColorEx</page> internally. ⤶ ⤶ <note>This doesn't apply to all VGUI elements (such as <page>DLabel</page>) and its function varies between them</note>⤶ </description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="r or color" type="number">The red channel of the color, or a &lt;page&gt;Color&lt;/page&gt;. If you pass the latter, the following three arguments are ignored.</arg>⤶ <arg name="g" type="number">The green channel of the color.</arg>⤶ <arg name="b" type="number">The blue channel of the color.</arg>⤶ <arg name="a" type="number">The alpha channel of the color.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Creates a <page>Label</page> and sets its text color to white.</description>⤶ <code>⤶ local label = vgui.Create( "Label" )⤶ ⤶ label:SetFGColor( Color( 255, 255, 255, 255 ) )⤶ </code>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>Sets the foreground color of a <page>RichText</page> to match the chat box format.</description>⤶ <code>⤶ -- Create a window frame⤶ TextFrame = vgui.Create("DFrame")⤶ TextFrame:SetSize(200, 50)⤶ TextFrame:Center()⤶ TextFrame:SetTitle("This is a color test")⤶ TextFrame:MakePopup()⤶ ⤶ -- RichText panel⤶ local richtext = vgui.Create("RichText", TextFrame)⤶ richtext:Dock(FILL)⤶ ⤶ -- Sample text⤶ richtext:SetText("Here is some light green text.")⤶ ⤶ -- When the panel is ready for layout, make the text light green⤶ function richtext:PerformLayout()⤶ self:SetFGColor(Color(153, 255, 153))⤶ end⤶ </code>⤶ <output></output>⤶ ⤶ </example>