Garry's Mod Wiki

DColorCube:SetColor

DColorCube:SetColor( table color )

Description

Sets the base color of the color cube and updates the slider position.

Arguments

1 table color
The color to set, uses Color.

Example

Picks the color at the center screen pixel and applies it to the base color of a color cube and its background panel.

-- 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))
Output:

Page Links


Special Pages


Wikis

?

Render Time: 82ms

DB GetPage 46
Generate Html 9
SaveChanges (1) 12
Render Body 0
Render Sidebar 12