// Based on Beziér Curve Code by Dan Pupius (www.pupius.net)
BezierCurve = function( x1, y1, x2, y2, x3, y3, x4, y4 ) {
	this.x1 = x1;
	this.y1 = y1;
	this.x2 = x2;
	this.y2 = y2;
	this.x3 = x3;
	this.y3 = y3;
	this.x4 = x4;
	this.y4 = y4;
	
	this.f1 = function(t) { return (t*t*t); }
	this.f2 = function(t) { return (3*t*t*(1-t)); } 
	this.f3 = function(t) { return (3*t*(1-t)*(1-t)); }
	this.f4 = function(t) { return ((1-t)*(1-t)*(1-t)); }
	
	/* p from 0 to 1 */
	this.x = function(p) { return this.x1*this.f1(p) + this.x2*this.f2(p) +this.x3*this.f3(p) + this.x4*this.f4(p); }
	this.y = function(p) { return this.y1*this.f1(p) + this.y2*this.f2(p) +this.y3*this.f3(p) + this.y4*this.f4(p); }
}