/**
 * Module exports.
 */

module.exports = Color;

function Color(r, g, b){
	this.red = this.green = this.blue = null;
	if (3 == arguments.length) {
		this.setRGB(r, g, b);
	}
}

/**
 * Set color values from RGB
 * @param {Integer} red
 * @param {Integer} green
 * @param {Integer} blue
 * @return {Color} self
 */
Color.prototype.setRGB = function (red, green, blue) {
	var setValue = function (value) {
		var v = parseInt(value);
		if (v < 0) {
			return 0;
		}
		if (v > 255) {
			return 255;
		}
		return v;
	};
	this.red   = setValue(red);
	this.green = setValue(green);
	this.blue  = setValue(blue);
	return this;
}

/**
 * @return {String}
 */
Color.prototype.toStringHEX = function () {
	var toHEX = function (intValue) {
		return (intValue < 16 ? '0' : '') + intValue.toString(16);
	}
	return '#' + toHEX(this.red) + toHEX(this.green) + toHEX(this.blue);
}

/**
 * @return {String}
 */
Color.prototype.toString = function () {
	return this.toStringHEX();
}

/**
 * Create color from RGB
 * @param {Integer} red
 * @param {Integer} green
 * @param {Integer} blue
 * @return {Color} self
 */
Color.fromRGB = function (red, green, blue) {
	var c = new Color();
	return c.setRGB(red, green, blue);
}


@@ -168,16 +168,112 @@
  g, b);%0A
+%09%7D else if (1 == arguments.length && this.isHEX(arguments%5B0%5D)) %7B%0A%09%09this.parseHEX(arguments%5B0%5D);%0A
 %09%7D%0A%7D%0A%0A/*
@@ -954,24 +954,478 @@
 s.blue);%0A%7D%0A%0A
+/**%0A * @return %7BBoolean%7D%0A */%0AColor.prototype.isHEX = function (value) %7B%0A%09return true%0A%09%09&& (typeof value == 'string' %7C%7C value instanceof String)%0A%09%09&& /%5E#?(?:%5B0-9a-f%5D%7B3%7D)%7B1,2%7D$/i.test(value)%0A%7D%0A%0A/**%0A * @return %7BColor%7D%0A */%0AColor.prototype.parseHEX = function (value) %7B%0A%09var c  = '(%5Ba-f0-9%5D%7B1,2%7D)',%0A%09%09%09re = new RegExp('%5E#?' + c + c + c + '$', 'i'),%0A%09%09%09m  = value.match(re);%0A%0A%09return this.setRGB(parseInt(m%5B1%5D, 16), parseInt(m%5B2%5D, 16), parseInt(m%5B3%5D, 16));%0A%7D%0A%0A
 /**%0A * @retu

Allow to parse HEX values from constructor