Fix hats on birds with tufts

This commit is contained in:
Idrees Hassan
2026-01-19 21:06:27 -05:00
parent 7628ee2c87
commit d97e39449e
9 changed files with 65 additions and 29 deletions

View File

@@ -44,11 +44,17 @@ class Frame {
}
/**
* @param {string} [tag]
* @param {string[]} [tags]
* @returns {string[][]}
*/
getPixels(tag = TAG.DEFAULT) {
return this.#pixelsByTag[tag] ?? this.#pixelsByTag[TAG.DEFAULT];
getPixels(tags = [TAG.DEFAULT]) {
for (let i = tags.length - 1; i >= 0; i--) {
const tag = tags[i];
if (this.#pixelsByTag[tag]) {
return this.#pixelsByTag[tag];
}
}
return this.#pixelsByTag[TAG.DEFAULT];
}
/**
@@ -62,7 +68,7 @@ class Frame {
// Clear the canvas before drawing the new frame
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
const pixels = this.getPixels(tags[0]);
const pixels = this.getPixels(tags);
for (let y = 0; y < pixels.length; y++) {
const row = pixels[y];
for (let x = 0; x < pixels[y].length; x++) {