DColorCube/UpdateColor

From Garry's Mod
Jump to: navigation, search
 DColorCube:UpdateColor( )

Contents

DescriptionPanelFunc

This is an internal function or feature.
This means you will be able to use it, but you really shouldn't.

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

Arguments

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

Arguments

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

Examples

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 )
Personal tools
Navigation