-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.js
36 lines (21 loc) · 819 Bytes
/
render.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
Render = function(document, canvas) {
this.document = document;
this.canvas = canvas;
this.document.invalidate.addListener(this.renderDocument.bind(this));
}
Render.prototype.renderDocument = function() {
var context = this.canvas.getContext("2d");
context.clearRect(0, 0, this.canvas.width, this.canvas.height);
context.strokeStyle = "black";
this.drawGeometries(this.document.getGeometries());
context.strokeStyle = "red";
this.drawGeometries(this.document.getEditionGeometries());
/*if (this.document.hasSelection())
this.document.getSelectedGeometry().drawSelection(context);*/
}
Render.prototype.drawGeometries = function(geometries) {
var context = this.canvas.getContext("2d");
geometries.forEach(function(geometry) {
geometry.draw(context);
}.bind(this));
}