function color(in_r, in_g, in_b)
{
	this.r=in_r;
	this.g=in_g;
	this.b=in_b;
}

color.prototype.clone = function()
{
	return new color(this.r, this.g, this.b);
}

color.prototype.scale = function(val)
{
	this.r *= val;
	this.g *= val;
	this.b *= val;
	
	return this;
}

color.prototype.negate = function()
{
	return new color(-this.r, -this.g, -this.b);
}

color.prototype.add_eq = function(in_c)
{
	this.r += in_c.r;
	this.g += in_c.g;
	this.b += in_c.b;
	
	return this;
}

color.prototype.mul_eq = function(in_c)
{
	this.r *= in_c.r;
	this.g *= in_c.g;
	this.b *= in_c.b;
	
	return this;
}

color.prototype.clamp = function(val)
{
	if(this.r < 0.0)
		this.r = 0.0;
	else if(this.r > val)
		this.r = val;
	
	if(this.g < 0.0)
		this.g = 0.0;
	else if(this.g > val)
		this.g = val;
		
	if(this.b < 0.0)
		this.b = 0.0;
	else if(this.b > val)
		this.b = val;
	
	return this;
}

function col_add(col1, col2)
{
	return new color(col1.r+col2.r, col1.g+col2.g, col1.b+col2.b);
}

function color_lerp(col1, col2, val)
{
	var ci_r = Math.round(col1.r + val * (col2.r - col1.r));
	var ci_g = Math.round(col1.g + val * (col2.g - col1.g));
	var ci_b = Math.round(col1.b + val * (col2.b - col1.b));

	return new color(ci_r, ci_g, ci_b);
}

