front_idill/src/search/js/curve.js
changeset 44 8393d3473b98
parent 35 4267d6d27a7d
equal deleted inserted replaced
43:cefce0845ac5 44:8393d3473b98
    23 	this.path;
    23 	this.path;
    24 	this.pathStroke;
    24 	this.pathStroke;
    25 	this.lastPoint;
    25 	this.lastPoint;
    26 }
    26 }
    27 
    27 
    28 curve.prototype.onMouseDown = function(event)
    28 curve.prototype.onPointerIn = function(pointerX, pointerY)
    29 {
    29 {
    30 	this.pathStroke = new Path();
    30 	this.pathStroke = new Path();
    31 	this.path = new Path();
    31 	this.path = new Path();
    32 	
    32 	
       
    33 	var point = new paper.Point(pointerX, pointerY);
       
    34 	
       
    35 	if(!this.lastPoint)
       
    36 	{
       
    37 		this.lastPoint = point;
       
    38 	}
       
    39 	
    33 	this.pathStroke.fillColor = '#366F7A';
    40 	this.pathStroke.fillColor = '#366F7A';
    34 	this.path.fillColor = '#02FEFF';
    41 	this.path.fillColor = '#02FEFF';
    35 	
       
    36 	console.log('down');
       
    37 };
    42 };
    38 
    43 
    39 curve.prototype.onMouseDrag = function(event)
    44 curve.prototype.onPointerMove = function(pointerX, pointerY)
    40 {
    45 {
    41 	//if(event.point.x < 0 || event.point.x > canvasWidth || event.point.y < 0 || event.point.y > canvasHeight)
    46 	var point = new paper.Point(pointerX, pointerY);
    42 		//return;
       
    43 	
    47 	
    44 	var step = event.delta / 5;
    48 	var delta = new paper.Point(this.lastPoint.x - point.x, this.lastPoint.y - point.y);
    45 	var stepStroke = event.delta / 3;
    49 	
       
    50 	var step = delta / 5;
       
    51 	var stepStroke = delta / 3;
    46 	step.angle += 90;
    52 	step.angle += 90;
    47 	stepStroke.angle += 90;
    53 	stepStroke.angle += 90;
    48 
    54 
    49 	var top = event.point + step;
    55 	var top = point + step;
    50 	var bottom = event.point - step;
    56 	var bottom = point - step;
    51 	
    57 	
    52 	var topStroke = event.point + stepStroke;
    58 	var topStroke = point + stepStroke;
    53 	var bottomStroke = event.point - stepStroke;
    59 	var bottomStroke = point - stepStroke;
    54 
    60 
    55 	this.path.add(top);
    61 	this.path.add(top);
    56 	this.path.insert(0, bottom);
    62 	this.path.insert(0, bottom);
    57 	this.path.smooth();
    63 	this.path.smooth();
    58 	
    64 	
    59 	this.pathStroke.add(topStroke);
    65 	this.pathStroke.add(topStroke);
    60 	this.pathStroke.insert(0, bottomStroke);
    66 	this.pathStroke.insert(0, bottomStroke);
    61 	this.pathStroke.smooth();
    67 	this.pathStroke.smooth();
    62 	
    68 	
    63 	this.lastPoint = event.middlePoint;
    69 	this.lastPoint = point;
    64 };
    70 };
    65 
    71 
    66 curve.prototype.onMouseUp = function(event)
    72 curve.prototype.onMouseUp = function(pointerX, pointerY)
    67 {
    73 {
    68 	this.pathStroke.remove();
    74 	this.pathStroke.remove();
    69 	this.path.remove();
    75 	this.path.remove();
    70 };
    76 };
    71 
    77