fantasy/painting/canvas.js
2018-11-18 21:14:06 +03:00

24 lines
547 B
JavaScript

import Color from "./color.js";
class Canvas {
constructor() {
this.element = document.createElement("canvas");
this.element.width = 1000;
this.element.height = 1000;
this._ctx = this.element.getContext("2d");
}
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();
}
}
export default Canvas;