forked from barais/tpWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
58 lines (49 loc) · 1.88 KB
/
Copy pathcontroller.js
File metadata and controls
58 lines (49 loc) · 1.88 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var editingMode = { rect: 0, line: 1 };
function Pencil(ctx, drawing, canvas) {
this.currEditingMode = editingMode.line;
this.currLineWidth = 5;
this.currColour = '#000000';
this.currentShape = 0;
// Liez ici les widgets à la classe pour modifier les attributs présents ci-dessus.
new DnD(canvas, this);
// Implémentez ici les 3 fonctions onInteractionStart, onInteractionUpdate et onInteractionEnd
this.onInteractionStart = function (DnD) {
ctx.clearRect(0,0,canvas.width, canvas.height);
//drawing.paint(ctx);
epaisseur = $('#spinnerWidth').val();
couleur = $('#colour').val();
if($('#butRect')[0].checked){
var rec = new Rectangle( DnD.posyfin - DnD.posyinit,DnD.posxfin - DnD.posxinit, DnD.posxinit, DnD.posyinit , epaisseur, couleur)
}else{
var line = new Line(DnD.posxinit, DnD.posyfin, 0, 0, epaisseur, couleur)
}
}
this.onInteractionUpdate= function (DnD){
ctx.clearRect(0,0,canvas.width, canvas.height);
drawing.paint(ctx);
epaisseur = $('#spinnerWidth').val();
couleur = $('#colour').val();
if($('#butRect')[0].checked){
var rec = new Rectangle( DnD.posyfin - DnD.posyinit,DnD.posxfin - DnD.posxinit, DnD.posxinit, DnD.posyinit , epaisseur, couleur)
rec.paint(ctx)
}else{
var line = new Line(DnD.posxinit, DnD.posyinit, DnD.posxfin, DnD.posyfin, epaisseur, couleur)
line.paint(ctx)
}
}
this.onInteractionEnd= function (DnD){
ctx.clearRect(0,0,canvas.width, canvas.height);
drawing.paint(ctx);
epaisseur = $('#spinnerWidth').val();
couleur = $('#colour').val();
if($('#butRect')[0].checked){
var rec = new Rectangle( DnD.posyfin - DnD.posyinit,DnD.posxfin - DnD.posxinit, DnD.posxinit, DnD.posyinit , epaisseur, couleur)
drawing.ajoutForme(rec)
rec.paint(ctx)
}else{
var line = new Line(DnD.posxinit, DnD.posyinit, DnD.posxfin, DnD.posyfin, epaisseur, couleur)
drawing.ajoutForme(line)
line.paint(ctx)
}
}
};