new! fast! WebGL renderer

This commit is contained in:
りき萌 2024-09-03 22:16:28 +02:00
parent bf4d538651
commit 83754a0282
6 changed files with 408 additions and 36 deletions

View file

@ -100,17 +100,17 @@ export class Pixmap {
return this.#pPixmap;
}
get imageData() {
return new ImageData(
new Uint8ClampedArray(
memory.buffer,
w.haku_pixmap_data(this.#pPixmap),
this.width * this.height * 4,
),
this.width,
this.height,
getArrayBuffer() {
return new Uint8ClampedArray(
memory.buffer,
w.haku_pixmap_data(this.#pPixmap),
this.width * this.height * 4,
);
}
getImageData() {
return new ImageData(this.getArrayBuffer(), this.width, this.height);
}
}
export class Haku {
@ -119,6 +119,8 @@ export class Haku {
#brushCode = null;
constructor(limits) {
console.groupCollapsed("construct Haku");
let pLimits = w.haku_limits_new();
for (let name of Object.keys(limits)) {
w[`haku_limits_set_${name}`](pLimits, limits[name]);
@ -128,6 +130,8 @@ export class Haku {
this.#pBrush = w.haku_brush_new();
w.haku_limits_destroy(pLimits);
console.groupEnd();
}
destroy() {