Документация
на русском v1.2.5 Документацитя по MooTools 1.4.5 Обсуждение Установить себе Благодарности
на русском v1.2.5 Документацитя по MooTools 1.4.5 Обсуждение Установить себе Благодарности
Creates a new Color Class, which is an array with some color specific methods.
var myColor = new Color(color[, type]);
There are three typical representations of color: String, RGB, and HSB. For String representation see Element:setStyle for more information.
'#fff'
[255, 255, 255] //Or: [255, 255, 255, 1] //(For transparency.)
var black = new Color('#000'); var purple = new Color([255,0,255]);
Mixes two or more colors with the Color.
var myMix = myColor.mix(color[, color2[, color3[, ...][, alpha]);
// mix black with white and purple, each time at 10% of the new color var darkpurple = new Color('#000').mix('#fff', [255, 0, 255], 10); $('myDiv').setStyle('background-color', darkpurple);
Inverts the Color.
var myInvert = myColor.invert();
var white = new Color('#fff'); var black = white.invert();
Modifies the hue of the Color, and returns a new one.
var hue = myColor.setHue(value);
var myColor = new Color('#f00'); var myElement = $('myElement'); (function(){ myElement.setStyle('color', myColor.setHue(myColor.hsb[0]++))); }).periodical(250);
Changes the saturation of the Color, and returns a new one.
var saturate = myColor.setSaturation(percent);
var myColor = new Color('#f00'); $('myElement').addEvent('mouseenter', function(){ this.setStyle('background-color', myColor.setSaturation(myColor.hsb[1]++)); });
Changes the brightness of the Color, and returns a new one.
var brighten = myColor.setBrightness(percent);
var myColor = new Color('#000'); $('myElement').addEvent('mouseenter', function(){ this.setStyle('background-color', myColor.setBrightness(myColor.hsb[2]++)); });
Shortcut to create a new color, based on red, green, blue values.
var myColor = $RGB(r, g, b);
var myColor = $RGB($random(0,255), $random(0,255), $random(0,255));
Shortcut to create a new color, based on: hue, saturation, brightness values.
var myColor = $HSB(h, s, b);
var myColor = $HSB(50, 50, 100);
Contains Array prototypes.
Converts a RGB array to an HSB array.
var myHSB = myRGBArray.rgbToHsb();
var myHSB = [255, 0, 0].rgbToHsb(); //Returns [0, 100, 100].
Converts an HSB array to a RGB array.
var myHSB = myRGBArray.hsbToRgb();
var myRGB = [0, 100, 100].hsbToRgb(); //myRGB = [255, 0, 0]
© Linux.ria.ua, 2008-2024 |