Color.js

Contains the Color class.

License

MIT-style license.

Summary
Color.jsContains the Color class.
ColorCreates a new Color Object, which is an array with some color specific methods.
Properties
mixMixes two or more colors with the Color.
invertInverts the Color.
setHueModifies the hue of the Color, and returns a new one.
setSaturationChanges the saturation of the Color, and returns a new one.
setBrightnessChanges the brightness of the Color, and returns a new one.
Utility Functions
Functions
$RGBShortcut to create a new color, based on red, green, blue values.
$HSBShortcut to create a new color, based on hue, saturation, brightness values.
ArrayA collection of The Array Object prototype methods.
Properties
rgbToHsbConverts a RGB array to an HSB array.
hsbToRgbConverts an HSB array to an RGB array.

Color

Creates a new Color Object, which is an array with some color specific methods.  Arguments: color - the hex, the RGB array or the HSB array of the color to create.  For HSB colors, you need to specify the second argument. type - a string representing the type of the color to create. needs to be specified if you intend to create the color with HSB values, or an array of HEX values.  Can be ‘rgb’, ‘hsb’ or ‘hex’.

Example

var black = new Color('#000');
var purple = new Color([255,0,255]);
// mix black with white and purple, each time at 10% of the new color
var darkpurple = black.mix('#fff', purple, 10);
$('myDiv').setStyle('background-color', darkpurple);
Summary
Properties
mixMixes two or more colors with the Color.
invertInverts the Color.
setHueModifies the hue of the Color, and returns a new one.
setSaturationChanges the saturation of the Color, and returns a new one.
setBrightnessChanges the brightness of the Color, and returns a new one.

Properties

mix

Mixes two or more colors with the Color.

Arguments

colora color to mix. you can use as arguments how many colors as you want to mix with the original one.
alphaif you use a number as the last argument, it will be threated as the amount of the color to mix.

invert

Inverts the Color.

setHue

Modifies the hue of the Color, and returns a new one.

Arguments

valuethe hue to set

setSaturation

Changes the saturation of the Color, and returns a new one.

Arguments

percentthe percentage of the saturation to set

setBrightness

Changes the brightness of the Color, and returns a new one.

Arguments

percentthe percentage of the brightness to set

Utility Functions

Summary
Functions
$RGBShortcut to create a new color, based on red, green, blue values.
$HSBShortcut to create a new color, based on hue, saturation, brightness values.

Functions

$RGB

Shortcut to create a new color, based on red, green, blue values.

Arguments

r(integer) red value (0-255)
g(integer) green value (0-255)
b(integer) blue value (0-255)

$HSB

Shortcut to create a new color, based on hue, saturation, brightness values.

Arguments

h(integer) hue value (0-100)
s(integer) saturation value (0-100)
b(integer) brightness value (0-100)

Array

A collection of The Array Object prototype methods.

Summary
Properties
rgbToHsbConverts a RGB array to an HSB array.
hsbToRgbConverts an HSB array to an RGB array.

Properties

rgbToHsb

Converts a RGB array to an HSB array.

Returns

the HSB array.

hsbToRgb

Converts an HSB array to an RGB array.

Returns

the RGB array.

Shortcut to create a new color, based on red, green, blue values.
Shortcut to create a new color, based on hue, saturation, brightness values.

Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi