DColorCube/TranslateValues

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

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 and returns its arguments. Similar to DColorCube:UpdateColor.

Arguments

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

Arguments

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

number

The given x position.

Returns

number

The given y position.

Examples

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 )
DColorCube TranslateValues example1.png
Personal tools
Navigation