Garry's Mod Wiki

Color

List of all possible functions to manipulate colors.

Colors are implemented in Lua thus type(color) == "table" and TypeID(color) == TYPE_TABLE.

For type checking use IsColor.

Created by Color, HSVToColor, and HSLToColor.

Type Name Description
number r The red component of the color.
number g The green component of the color.
number b The blue component of the color.
number a The alpha component of the color.

Methods

Color:AddBlackness( number blackness )
Converts a Color into HWB color space, adds given value to the "blackness" and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetBlackness & COLOR:SetBlackness
Color:AddBrightness( number saturation )
Converts a Color into HSV color space, adds given value to the brightness also known as "value" and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetBrightness & COLOR:SetBrightness This is useful to quickly change the saturation of the color without changing hue or luminance, allowing for things like easy theming.
Color:AddHue( number hue )
Converts a Color into HSV color space, adds given value to the hue and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetHue & COLOR:SetHue This is useful to quickly change the hue of the color without changing saturation or luminance, allowing for things like easy theming.
Color:AddLightness( number lightness )
Converts a Color into HSL color space, adds given value to the "lightness" and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetLightness & COLOR:SetLightness This is useful to quickly change the lightness of the color without changing hue or saturation, allowing for things like easy theming.
Color:AddSaturation( number saturation )
Converts a Color into HSV color space, adds given value to the saturation and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetSaturation & COLOR:SetSaturation This is useful to quickly change the saturation of the color without changing hue or luminance, allowing for things like easy theming.
Color:AddWhiteness( number whiteness )
Converts a Color into HWB color space, adds given value to the "whiteness" and converts it back into an RGB color. A slightly more efficient combination of COLOR:GetWhiteness & COLOR:SetWhiteness
Converts a Color into HWB color space and returns the "blackness" of the color. See COLOR:ToHWB if you want to get all 3 components.
Converts a Color into HSV color space and returns the brightness also known as "value". See COLOR:ToHSV if you want to get all 3 components.
number Color:GetHue()
Converts a Color into HSV color space and returns the hue. See COLOR:ToHSV if you want to get all 3 components.
Converts a Color into HSL color space and returns the "lightness" of the color. See COLOR:ToHSL if you want to get all 3 components.
Converts a Color into HSV color space and returns the saturation. See COLOR:ToHSV if you want to get all 3 components.
Converts a Color into HWB color space and returns the "whiteness" of the color. See COLOR:ToHWB if you want to get all 3 components.
Color Color:Lerp( Color target, number fraction )
Performs linear interpolation between this and given colors.
Color:SetBlackness( number blackness )
Converts a Color into HWB color space, sets the "blackness" and converts it back into an RGB color.
Color:SetBrightness( number saturation )
Converts a Color into HSV color space, sets the brightness also known as "value" and converts it back into an RGB color. This is useful to quickly change the brightness of the color without changing hue or saturation, allowing for things like easy theming.
Color:SetHue( number hue )
Converts a Color into HSV color space, sets the hue and converts it back into an RGB color. This is useful to quickly change the hue of the color without changing saturation or luminance, allowing for things like easy theming.
Color:SetLightness( number lightness )
Converts a Color into HSL color space, sets the "lightness" and converts it back into an RGB color. This is useful to quickly change the lightness of the color without changing hue or saturation, allowing for things like easy theming.
Color:SetSaturation( number saturation )
Converts a Color into HSV color space, sets the saturation and converts it back into an RGB color. This is useful to quickly change the saturation of the color without changing hue or luminance, allowing for things like easy theming.
Color:SetUnpacked( number r, number g, number b, number a )
Sets the red, green, blue, and alpha of the color.
Color:SetWhiteness( number whiteness )
Converts a Color into HWB color space, sets the "whiteness" and converts it back into an RGB color.
Converts a Color into HSL color space . This calls ColorToHSL internally.
Encodes a RGB Color into the HSV color space. This function uses ColorToHSV internally.
Converts a Color into HWB color space. See HWBToColor for more info.
table Color:ToTable()
Returns the color as a table (an array or a list) with four elements.
Translates the Color into a Vector, losing the alpha channel. This will also range the values from 0 - 255 to 0 - 1 r / 255 -> x g / 255 -> y b / 255 -> z This is the opposite of Vector:ToColor
Returns the red, green, blue, and alpha of the color.