forked from barais/tpWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.js
More file actions
33 lines (25 loc) · 808 Bytes
/
view.js
File metadata and controls
33 lines (25 loc) · 808 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
33
// Implémenter ici les fonctions paint à ajouter dans chacune des classes du modèle.
Rectangle.prototype.paint = function(ctx) {
ctx.beginPath();
ctx.rect(this.x_topLeft, this.y_topLeft, this.width, this.height);
ctx.stroke();
};
Line.prototype.paint = function(ctx) {
ctx.beginPath();
ctx.moveTo( this.x_A , this.y_A);
ctx.lineTo( this.x_B , this.y_B);
ctx.stroke();
};
Drawing.prototype.paint = function(ctx) {
//console.log(this.getForms());
ctx.fillStyle = '#F0F0F0'; // set canvas' background color
ctx.fillRect(0, 0, canvas.width, canvas.height);
this.getForms().forEach(function (eltDuTableau) {
// now fill the canvas
eltDuTableau.paint(ctx);
});
};
Form.prototype.paint = function(ctx) {
ctx.strokeStyle = this.color;
ctx.lineWidth = this.thickness;
};