visual fixes

This commit is contained in:
Blue 2018-11-19 18:03:05 +03:00
parent abfeb77fa5
commit 005f498e1e
6 changed files with 50 additions and 30 deletions

View file

@ -1,35 +0,0 @@
import Color from "./color.js";
class Canvas {
constructor(width, height) {
this.element = document.createElement("canvas");
this.element.width = width;
this.element.height = height;
this._ctx = this.element.getContext("2d");
this._width = width;
this._height = height;
}
clear() {
this.resetStyle();
this._ctx.clearRect(0, 0, this._width, this._height);
}
setFillColor(color) {
this._ctx.fillStyle = color.rgba();
}
resetStyle() {
this._ctx.fillStyle = "";
}
draw(shape) {
this._ctx.fillStyle = shape.color.rgba();
shape.draw(this._ctx);
this.resetStyle();
}
resize(width, height) {
this.element.width = width;
this.element.height = height;
this._width = width;
this._height = height;
}
}
export default Canvas;