Garry's Mod Wiki


  DColorCube:SetColor( table color )


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


1 table color
The color to set, uses Color.


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