-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw-line.js
More file actions
38 lines (32 loc) · 1.03 KB
/
draw-line.js
File metadata and controls
38 lines (32 loc) · 1.03 KB
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
33
34
35
36
37
38
class DrawingLine extends PaintFunction{
constructor(contextReal){
super();
this.contextReal = contextReal;
this.contextDraft = contextDraft;
}
onMouseDown(coord,event){
this.origX = coord[0];
this.origY = coord[1];
}
onDragging(coord,event){
//this.contextDraft.fillStyle = "#f44"
//this.contextDraft.lineWidth = 5;
this.contextDraft.clearRect(0,0,canvasDraft.width,canvasDraft.height);
this.contextDraft.beginPath();
this.contextDraft.moveTo(this.origX, this.origY)
this.contextDraft.lineTo(coord[0],coord[1])
this.contextDraft.stroke();
}
onMouseMove(){
}
onMouseUp(coord){
this.contextDraft.clearRect(0,0,canvasDraft.width,canvasDraft.height);
this.contextReal.beginPath();
this.contextReal.moveTo(this.origX, this.origY)
this.contextReal.lineTo(coord[0],coord[1])
this.contextReal.stroke()
}
onMouseLeave(){
}
onMouseEnter(){}
}