-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcontroller.js
46 lines (33 loc) · 1.31 KB
/
controller.js
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
39
40
41
42
43
44
45
46
//var editingMode = { rect: 0, line: 1 };
function Pencil(ctx, drawing, canvas) {
this.currentShape = 0;
this.ctx = ctx;
// Liez ici les widgets à la classe pour modifier les attributs présents ci-dessus.
new DnD(canvas, this);
this.onInteractionStart = function(dnd) {
if (document.getElementById("butRect").checked){
this.currentShape = new Rectangle(dnd.initX,dnd.initY,dnd.finalX,dnd.finalY,
document.getElementById("spinnerWidth").value, document.getElementById("colour").value);
}else{
this.currentShape = new Line(dnd.initX,dnd.initY,dnd.finalX,dnd.finalY,
document.getElementById("spinnerWidth").value, document.getElementById("colour").value);
}
}.bind(this) ;
this.onInteractionUpdate = function(dnd) {
if (this.currentShape != 0){
this.currentShape.clear(this.ctx)
this.currentShape.finalX = dnd.finalX;
this.currentShape.finalY = dnd.finalY;
drawing.paint(this.ctx);
this.currentShape.paint(this.ctx);
}
}.bind(this) ;
this.onInteractionEnd = function(dnd) {
this.currentShape.finalX = dnd.finalX;
this.currentShape.finalY = dnd.finalY;
this.currentShape.paint(this.ctx);
drawing.addForms(this.currentShape);
drawing.paint(this.ctx);
}.bind(this) ;
// Implémentez ici les 3 fonctions onInteractionStart, onInteractionUpdate et onInteractionEnd
};