Garry's Mod Wiki

Revision Difference

Panel:SetBGColor#550870

<function name="SetBGColor" parent="Panel" type="classfunc"> <description> Sets the background color of a panel such as a <page>RichText</page>, <page>Label</page> or <page>DColorCube</page>. <note>This doesn't apply to all VGUI elements and its function varies between them</note> For <page>DLabel</page> elements, you must use <page>Panel:SetPaintBackgroundEnabled</page>( true ) before applying the color. This will not work on setup of the panel - you should use this function in a hook like <page>PANEL:ApplySchemeSettings</page> or <page>PANEL:PerformLayout</page>. </description> <realm>Client</realm>⤶ <realm>Client and Menu</realm>⤶ <args> <arg name="r or color" type="number">The red channel of the color, or a <page>Color</page>. 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 RichText panel that mimics a [blue screen of death](http://en.wikipedia.org/wiki/Blue_Screen_of_Death).</description> <code> -- Create a window frame TextFrame = vgui.Create("DFrame") TextFrame:SetSize(300, 100) TextFrame:Center() TextFrame:SetTitle("Windows XP Blue Screen") TextFrame:MakePopup() -- RichText panel local richtext = vgui.Create("RichText", TextFrame) richtext:Dock(FILL) -- Sample text richtext:SetText("A problem has been detected and Windows has been shut down to prevent damage to your computer.\n\nMOTHERBOARD_FRIED") -- When the panel is ready for layout, set the background color to blue function richtext:PerformLayout() self:SetBGColor(Color(0, 0, 255)) end </code> <output><image src="RichText_SetBGColor_example1.png"/></output> </example>