font fix, blur, coloring controls

This commit is contained in:
Blue 2018-11-20 17:30:01 +03:00
parent 8511d8d2ec
commit 34c3030e13
5 changed files with 26 additions and 3 deletions

View file

@ -3,7 +3,10 @@ import UI from "./ui.js";
class Canvas extends UI {
constructor(width, height) {
super(document.createElement("canvas"), width, height);
this._blurStrength = 0;
this._ctx = this.element.getContext("2d");
this._ctx.filter = "blur(" + this._blurStrength + "px)";
}
clear() {
this.resetStyle();
@ -14,6 +17,7 @@ class Canvas extends UI {
}
resetStyle() {
this._ctx.fillStyle = "";
this._ctx.filter = "blur(" + this._blurStrength + "px)";
}
draw(shape) {
this._ctx.fillStyle = shape.color.rgba();
@ -26,6 +30,10 @@ class Canvas extends UI {
this.element.width = width;
this.element.height = height;
}
setBlurStrength(num) {
this._blurStrength = parseInt(num) || 0;
this._ctx.filter = "blur(" + this._blurStrength + "px)";
}
}
export default Canvas;