
Код:
Color.prototype.negative = function()
{
var trans = {};
trans.ra = trans.ga=trans.ba=-100;
trans.rb = trans.gb=trans.bb=255;
this.setTransform(trans);
};
Object.prototype.HEXtoRGB = function(hex)
{
var rgb24 = (isNaN(hex)) ? parseInt(hex, 16) : hex;
var r = rgb24 >> 16;
var g = (rgb24 ^ (r << 16)) >> 8;
var b = (rgb24 ^ (r << 16)) ^ (g << 8);
return {r:r, g:g, b:b};
};
Color.prototype.getGray = function()
{
var RGB = this.getTransform();
var gray = Math.round(.3*RGB.rb+.59*RGB.gb+.11*RGB.bb);
return {rb:gray, gb:gray, bb:gray};
};
example:
col = new Color(_root.movie);
col2 = new Color(_root.movie_2);
col.setTransform({rb:40, gb:255, bb:40});
col2.setTransform(col.getGray());
col.negative();