Skip to content

Commit

Permalink
refactor: PixMap.
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed Jan 7, 2024
1 parent d5089a7 commit a311d51
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/js/jagex2/graphics/PixMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ export default class PixMap {
this.bind();
}

clear(): void {
clear = (): void => {
this.pixels.fill(0);
}
};

bind(): void {
bind = (): void => {
Draw2D.prepare(this.pixels, this.width, this.height);
}
};

draw(width: number, height: number): void {
draw = (width: number, height: number): void => {
this.#setPixels();
this.ctx.putImageData(this.image, width, height);
}
};

#setPixels(): void {
#setPixels = (): void => {
// copy pixels (uint32) to imageData (uint8)
const data = this.image.data;
for (let i = 0; i < this.pixels.length; i++) {
Expand All @@ -47,5 +47,5 @@ export default class PixMap {
data[index + 2] = (pixel >> 0) & 0xff;
data[index + 3] = 255;
}
}
};
}

0 comments on commit a311d51

Please sign in to comment.