Class Index | File Index | UML

Classes


Class one.color.RGB


UML

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.

Class Summary
Constructor Attributes Constructor Name and Description
 
one.color.RGB(r, g, b, a)
Field Summary
Field Attributes Field Name and Description
 
a
The alpha value, range: [0.
 
b
The blue component, range: [0.
 
g
The green component, range: [0.
 
r
The red component, range: [0.
Method Summary
Method Attributes Method Name and Description
 
 
 
 
 
 
 
 
setRed(r)
 
Convert the color to a one.color.CMYK object.
 
Convert the color to a one.color.HSL object.
 
Convert the color to a one.color.HSV object.
 
Convert the color to a JSON representation.
 
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}

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Oct 17 2011 19:23:47 GMT+0200 (CEST)