Garry's Mod Wiki

DColorCube:UpdateColor

  DColorCube:UpdateColor( number x = nil, number y = nil )

Description

This is used internally - although you're able to use it you probably shouldn't.

Updates the color cube RGB based on the given x and y position. Similar to DColorCube:TranslateValues.

Arguments

1 number x = nil
The x position to set color to/the percentage of saturation to remove from the color (ranges from 0.0 to 1.0).
2 number y = nil
The y position to set color to/the percentage of brightness or value to remove from the color (ranges from 0.0 to 1.0).

Example

Creates a yellow color cube and updates/prints out the color at the (0.1, 0.6) position.

local color_cube = vgui.Create("DColorCube") color_cube:SetSize(200, 200) color_cube:Center() -- Set base color to yellow color_cube:SetColor(Color(255, 255, 0)) -- 10% less saturation, 60% darker color_cube:UpdateColor(0.1, 0.6) -- Get new color local new_color = color_cube:GetRGB() -- Print new color print("Color( "..new_color.r..", "..new_color.g..", "..new_color.b..", "..new_color.a.." )")
Output:
Color( 102, 102, 10, 255 )