brush picker!

This commit is contained in:
りき萌 2025-06-19 13:48:07 +02:00
parent 9b82b211b4
commit c1612b2a94
12 changed files with 849 additions and 45 deletions

View file

@ -1,19 +1,23 @@
import { Pixmap } from "rkgk/haku.js";
export class BrushPreview extends HTMLElement {
constructor() {
constructor(width, height) {
super();
this.width = width;
this.height = height;
}
connectedCallback() {
this.canvas = this.appendChild(document.createElement("canvas"));
this.ctx = this.canvas.getContext("2d");
this.#resizeCanvas();
}
#resizeCanvas() {
this.canvas.width = this.clientWidth;
this.canvas.height = this.clientHeight;
this.canvas.width = this.width ?? this.clientWidth;
this.canvas.height = this.height ?? this.clientHeight;
if (this.pixmap != null) {
this.pixmap.destroy();
@ -51,6 +55,7 @@ export class BrushPreview extends HTMLElement {
this.unsetErrorFlag();
let result = await this.#renderBrushInner(haku);
if (result.status == "error") {
console.error(result);
this.setErrorFlag();
}
return result;