Revision Difference
DColorCube:SetColor#513281
<function name="SetColor" parent="DColorCube" type="panelfunc">⤶
<ispanel>yes</ispanel>⤶
<description>Sets the base color of the color cube and updates the slider position.</description>⤶
<realm>Client</realm>⤶
<args>⤶
<arg name="color" type="table">The color to set, uses <page>Color</page>.</arg>⤶
</args>⤶
</function>⤶
⤶
<example>⤶
<description>Picks the color at the center screen pixel and applies it to the base color of a color cube and its background panel.</description>⤶
<code>⤶
-- Get the color of the pixel at the center of the screen⤶
render.CapturePixels()⤶
local p_r, p_g, p_b = render.ReadPixel(ScrW()/2, ScrH()/2)⤶
⤶
-- Background panel⤶
BGPanel = vgui.Create("DPanel")⤶
BGPanel:SetPos((ScrW()/2)-50, ScrH()/2-100)⤶
BGPanel:SetSize(100, 100)⤶
⤶
-- Color cube⤶
local color_cube = vgui.Create("DColorCube", BGPanel)⤶
color_cube:SetSize(75, 75)⤶
color_cube:Center()⤶
⤶
-- Set the color to the center pixel color⤶
color_cube:SetColor(Color(p_r, p_g, p_b))⤶
⤶
-- Change background color too⤶
BGPanel:SetBackgroundColor(Color(p_r, p_g, p_b))⤶
</code>⤶
<output></output>⤶
⤶
</example>