///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////

function _bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)
{
	this.cp1x = cp1x;
	this.cp1y = cp1y;
	this.cp2x = cp2x;
	this.cp2y = cp2y;
	this.x = x;
	this.y = y;

	this.functionMeta = _bezierCurveTo.functionMeta;
}

_bezierCurveTo.prototype = new pathSeg();

///////////////////////////////////////////////////////////////////////////////////////////////////

_bezierCurveTo.functionMeta = 
{
	functionName:'bezierCurveTo',
	functionArgs:
	[
		{
			name:'cp1x',
			text:'x position of control point 1',
			type:'float'
		}, {
			name:'cp1y',
			text:'y position of control point 1',
			type:'float'
		}, {
			name:'cp2x',
			text:'x position of control point 2',
			type:'float'
		}, {
			name:'cp2y',
			text:'y position of control point 2',
			type:'float'
		}, {
			name:'x',
			text:'final x position of cursor',
			type:'float'
		}, {
			name:'y',
			text:'final y position of cursor',
			type:'float'
		}
	],
	controlPoints:
	{
		cp1:{
			name:'cp1',
			description:'1st control point',
		},
		cp2:{
			name:'cp2',
			description:'2nd control point',
		},
		cursor:{
			name:'cursor',
			description:'cursor position at end of drawing',
		}
	}
};

///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Control Point to Function Value Conversion
//
///////////////////////////////////////////////////////////////////////////////////////////////////

_bezierCurveTo.prototype.setControlPoint = function(cp, x, y)
{
	// can even match on object relations (probably - may impact of fluid flow of data)
	if (cp.name == 'cp1')
	{
		this.cp1x = x;
		this.cp1y = y;
	}
	else if (cp.name == 'cp2')
	{
		this.cp2x = x;
		this.cp2y = y;
	}
	else if (cp.name == 'cursor')
	{
		this.x = x;
		this.y = y;
	}
}

_bezierCurveTo.prototype.toControlPoints = function()
{
	var out = {
		cp1:{
			name:'cp1',
			x:this.cp1x,
			y:this.cp1y,
			model:this
		},
		cp2:{
			name:'cp2',
			x:this.cp2x,
			y:this.cp2y,
			model:this
		},
		cursor:{
			name:'cursor',
			x:this.x,
			y:this.y,
			model:this
		}
	};

	return out;
}

