front_idill/src/search/js/curve.js
changeset 44 8393d3473b98
parent 35 4267d6d27a7d
--- a/front_idill/src/search/js/curve.js	Fri Jun 29 15:46:34 2012 +0200
+++ b/front_idill/src/search/js/curve.js	Fri Jun 29 16:16:24 2012 +0200
@@ -25,32 +25,38 @@
 	this.lastPoint;
 }
 
-curve.prototype.onMouseDown = function(event)
+curve.prototype.onPointerIn = function(pointerX, pointerY)
 {
 	this.pathStroke = new Path();
 	this.path = new Path();
 	
+	var point = new paper.Point(pointerX, pointerY);
+	
+	if(!this.lastPoint)
+	{
+		this.lastPoint = point;
+	}
+	
 	this.pathStroke.fillColor = '#366F7A';
 	this.path.fillColor = '#02FEFF';
-	
-	console.log('down');
 };
 
-curve.prototype.onMouseDrag = function(event)
+curve.prototype.onPointerMove = function(pointerX, pointerY)
 {
-	//if(event.point.x < 0 || event.point.x > canvasWidth || event.point.y < 0 || event.point.y > canvasHeight)
-		//return;
+	var point = new paper.Point(pointerX, pointerY);
 	
-	var step = event.delta / 5;
-	var stepStroke = event.delta / 3;
+	var delta = new paper.Point(this.lastPoint.x - point.x, this.lastPoint.y - point.y);
+	
+	var step = delta / 5;
+	var stepStroke = delta / 3;
 	step.angle += 90;
 	stepStroke.angle += 90;
 
-	var top = event.point + step;
-	var bottom = event.point - step;
+	var top = point + step;
+	var bottom = point - step;
 	
-	var topStroke = event.point + stepStroke;
-	var bottomStroke = event.point - stepStroke;
+	var topStroke = point + stepStroke;
+	var bottomStroke = point - stepStroke;
 
 	this.path.add(top);
 	this.path.insert(0, bottom);
@@ -60,10 +66,10 @@
 	this.pathStroke.insert(0, bottomStroke);
 	this.pathStroke.smooth();
 	
-	this.lastPoint = event.middlePoint;
+	this.lastPoint = point;
 };
 
-curve.prototype.onMouseUp = function(event)
+curve.prototype.onMouseUp = function(pointerX, pointerY)
 {
 	this.pathStroke.remove();
 	this.path.remove();