Color对象的几个扩展方法

 
Color.prototype.colorDodge = function(r, g, b) {
	var trans = new Object();
	trans.ra = 100/((258-r)/256);
	trans.ga = 100/((258-g)/256);
	trans.ba = 100/((258-b)/256);
	this.setTransform(trans);
};
Color.prototype.linearDodge = function(r, g, b) {
	var trans = new Object();
	trans.rb = r;
	trans.gb = g;
	trans.bb = b;
	this.setTransform(trans);
};
Color.prototype.linearBurn = function(r, g, b) {
	var trans = new Object();
	trans.rb = r-255;
	trans.gb = g-255;
	trans.bb = b-255;
	this.setTransform(trans);
};
Color.prototype.screen = function(r, g, b) {
	var trans = new Object();
	trans.rb = r;
	trans.ra = 100*(255-r)/255;
	trans.gb = g;
	trans.ga = 100*(255-g)/255;
	trans.bb = b;
	trans.ba = 100*(255-b)/255;
	this.setTransform(trans);
};
Color.prototype.invertRGB = function() {
	this.setRGB(0xffffff-this.getRGB());
};
Color.prototype.setBrightness = function(bright) {
	var percent = 100-Math.abs(bright);
	var offset = 0;
	if (bright>0) {
		offset = 256*(bright/100);
	}
	var trans = new Object();
	trans.ra = trans.ga=trans.ba=percent;
	trans.rb = trans.gb=trans.bb=offset;
	this.setTransform(trans);
};
Close
E-mail It
Socialized through Gregarious 42