Garry's Mod Wiki

DColorCube:SetBaseRGB

  DColorCube:SetBaseRGB( table color )

Description

An AccessorFunc that sets the base color and the color used to draw the color cube panel itself.

Calling this when using a color that isn't 100% saturated and valued (HSVToColor with saturation and value set to 1) causes the color cube to look inaccurate compared to the color that's returned by methods like DColorCube:GetRGB and DColorCube:OnUserChanged. You should use DColorCube:SetColor instead

Arguments

1 table color
The base color to set, uses Color.

Example

Creates a background panel and color cube that controls the background color. Demonstrates how setting the base RGB explicitly can cause a disconnect between the color represented by the cube and the color output.

-- Background panel BGPanel = vgui.Create("DPanel") BGPanel:SetSize(200, 200) BGPanel:Center() -- Color cube local color_cube = vgui.Create("DColorCube", BGPanel) color_cube:SetSize(180, 180) color_cube:Center() -- Base color set to white color_cube:SetBaseRGB(Color(255, 255, 255)) -- Called when the color is changed by user input function color_cube:OnUserChanged(col) -- Update background panel color BGPanel:SetBackgroundColor(col) end
Output: Notice how the output/background color doesn't match the color where the slider is positioned.