- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine.js
More file actions
Latest commit
32 lines (26 loc) · 613 Bytes
/
Copy pathLine.js
File metadata and controls
32 lines (26 loc) · 613 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
varLine=Shape.extend({
constructor: function(){
this.base("Line");
},
draw: function(canvas){
canvas.beginPath();
canvas.strokeStyle=this.color;
canvas.moveTo(this.pos.x,this.pos.y);
canvas.lineTo(this.size.x,this.size.y);
canvas.stroke();
},
drawing:function(point){
this.size.x=point.x-this.pos.x;
this.size.y=point.y-this.pos.y;
},
added: function(canvas){
if(this.size.x<0){
this.pos.x+=this.size.x;
this.size.x=Math.abs(this.size.x);
}
if(this.size.y<0){
this.pos.y+=this.size.y;
this.size.y=Math.abs(this.size.y);
}
},
});