DColorCube:TranslateValues
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 and returns its arguments. Similar to DColorCube:UpdateColor.
Arguments
1 number x
The x position to sample color from/the percentage of saturation to remove from the color (ranges from 0.0 to 1.0).
2 number y
The y position to sample color from/the percentage of brightness or value to remove from the color (ranges from 0.0 to 1.0).
Returns
Example
Creates a green color cube and prints out the color at the (0.2, 0.4) position.
local color_cube = vgui.Create("DColorCube")
color_cube:SetSize(200, 200)
color_cube:Center()
-- Set base color to green
color_cube:SetColor(Color(0, 255, 0))
-- 20% desaturated, 40% darker
color_cube:TranslateValues(0.2, 0.4)
-- Get new color
local new_color = color_cube:GetRGB()
-- Update slider position
color_cube:SetColor(new_color)
-- Print out new color
print("Color( "..new_color.r..", "..new_color.g..", "..new_color.b..", "..new_color.a.." )")
Output:
Color( 30, 153, 30, 255 )