Class one.color.RGB
A color in the RGB colorspace with an optional alpha value.
one.color.(RGB|HSL|HSV|CMYK) objects are designed to be immutable; all the conversion, set, and adjust methods return new objects.
one.color.(RGB|HSL|HSV|CMYK) objects automatically get the set and adjust methods from all other installed colorspaces, so although you can use the explicit conversion methods ({@link one.color.RGB#toHSL}, one.color.RGB#toCMYK...), the below will work just fine:
one.include('jslib:one/color/RGB.js');
one.include('jslib:one/color/HSL.js');
new one.color.RGB(.4, .3, .9).
adjustLightness(+.2). // Implicit conversion to HSL
setRed(-.1). // Implicit conversion back to RGB
toHex(); // "#00a6f2"
Defined in: RGB.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
one.color.RGB(r, g, b, a)
|
| Field Attributes | Field Name and Description |
|---|---|
|
The alpha value, range: [0.
|
|
|
The blue component, range: [0.
|
|
|
The green component, range: [0.
|
|
|
The red component, range: [0.
|
| Method Attributes | Method Name and Description |
|---|---|
|
adjustAlpha(a)
|
|
|
adjustBlue(b)
|
|
|
adjustGreen(g)
|
|
|
adjustRed(r)
|
|
|
setAlpha(a)
|
|
|
setBlue(b)
|
|
|
setGreen(g)
|
|
|
setRed(r)
|
|
|
toCMYK()
Convert the color to a one.color.CMYK object.
|
|
|
toHSL()
Convert the color to a one.color.HSL object.
|
|
|
toHSV()
Convert the color to a one.color.HSV object.
|
|
|
toJSON()
Convert the color to a JSON representation.
|
|
|
toRGB()
Convert the color to a one.color.RGB object, ie.
|
Class Detail
one.color.RGB(r, g, b, a)
- Parameters:
- {Number} r
- The red component, range: [0..1]
- {Number} g
- The green component, range: [0..1]
- {Number} b
- The blue component, range: [0..1]
- {Number} a Optional
- The alpha value, range: [0..1], defaults to 1
Field Detail
{Number}
a
The alpha value, range: [0..1]
{Number}
b
The blue component, range: [0..1]
{Number}
g
The green component, range: [0..1]
{Number}
r
The red component, range: [0..1]
Method Detail
{one.color.RGB}
adjustAlpha(a)
- Parameters:
- {Number} a
- The value to add to the alpha value. If the resulting value falls outside the supported range, [0..1], it will be adjusted automatically.
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
adjustBlue(b)
- Parameters:
- {Number} b
- The value to add to the blue component. If the resulting value falls outside the supported range, [0..1], it will be adjusted automatically.
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
adjustGreen(g)
- Parameters:
- {Number} g
- The value to add to the green component. If the resulting value falls outside the supported range, [0..1], it will be adjusted automatically.
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
adjustRed(r)
- Parameters:
- {Number} r
- The value to add to the red component. If the resulting value falls outside the supported range, [0..1], it will be adjusted automatically.
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
setAlpha(a)
- Parameters:
- {Number} a
- The new alpha value, range: [0..1]
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
setBlue(b)
- Parameters:
- {Number} b
- The new blue component, range: [0..1]
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
setGreen(g)
- Parameters:
- {Number} g
- The new green component, range: [0..1]
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.RGB}
setRed(r)
- Parameters:
- {Number} r
- The new red component, range: [0..1]
- Returns:
- {one.color.RGB} New color object with the changed value.
{one.color.CMYK}
toCMYK()
Convert the color to a one.color.CMYK object.
- Returns:
- {one.color.CMYK}
- Requires:
- one.color.CMYK
{one.color.HSL}
toHSL()
Convert the color to a one.color.HSL object.
- Returns:
- {one.color.HSL}
- Requires:
- one.color.HSL
{one.color.HSV}
toHSV()
Convert the color to a one.color.HSV object.
- Returns:
- {one.color.HSV}
- Requires:
- one.color.HSV
{Array}
toJSON()
Convert the color to a JSON representation.
- Returns:
- {Array}
{one.color.RGB}
toRGB()
Convert the color to a one.color.RGB object, ie. return the
object itself.
- Returns:
- {one.color.RGB}