From 5e94998410b234560df21474e5fc78b6a27ddbbe Mon Sep 17 00:00:00 2001 From: Idrees Hassan Date: Sun, 18 Jan 2026 17:03:14 -0500 Subject: [PATCH] Move sprite related files to separate folder --- dist/extension.zip | Bin 149603 -> 149603 bytes dist/extension/birb.js | 2 +- dist/extension/manifest.json | 2 +- dist/obsidian/main.js | 4 +- dist/obsidian/manifest.json | 2 +- dist/userscript/birb.user.js | 4 +- dist/web/birb.embed.js | 2 +- dist/web/birb.js | 2 +- src/Frame.js | 76 --------------------------------- src/Layer.js | 12 ------ src/{ => animation}/anim.js | 0 src/{ => animation}/frame.js | 2 +- src/{ => animation}/layer.js | 0 src/{ => animation}/sprites.js | 0 src/application.js | 8 ++-- src/birb.js | 8 ++-- 16 files changed, 18 insertions(+), 106 deletions(-) delete mode 100644 src/Frame.js delete mode 100644 src/Layer.js rename src/{ => animation}/anim.js (100%) rename src/{ => animation}/frame.js (98%) rename src/{ => animation}/layer.js (100%) rename src/{ => animation}/sprites.js (100%) diff --git a/dist/extension.zip b/dist/extension.zip index 9db8461b996746312b37247b0ba5ea6283a99cc4..8cd4185402fe83f3ce6f1951f17389c92e7c3cc4 100644 GIT binary patch delta 1285 zcmaDnf%EYM&J9agnIkqBZC=j0*_A1#baRaN3R%gu_MKB4lNlJabr=}}yqQ_J7(f81 zY_e>oB1n0&W9D|pOh#1?5NCSkMn)45WBY=QjI3;6){5zYp}iYHRD}4S9g2cd&U$buGD7~NlhF2LVJ2;eyC;e>`LPHB zVb%o%)X$vip!~C zM`1)Je|5Ct=|Z)&iW_@vm&Pvq_g&Un|IlLgH7=X}o_+m0?N8N_jE`O-{+pO2Ay7;B_q?hX6hAJ=>+lRhwi z)7vPe>^1Dm-qbJCQ$Drr(gR=lf-~oyr+;=eJDqk~F8VgxoS4QNKdi28b}M;kbiVW@ zW0RRy@V1w|TQ{jqxSIWFg2p`k#nbaNTuunjTRdIO;^o1Fx_x&pnxCE%S?W0H`q4)V zt{+Wuzt6t@=AQziL*+01U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a^hZ}fb2VwHmSGTz_G*XN1e%VYWx zye-l*rT6QBDY5m}Q(bPlN$q*d+;{WmpPYRs(r&(4b3AMtqxy7(Yy0}Xt`UgcajH1B zs$oIzsVTWt$!pherhJ`fq0;qS{GzwHh|&|z^B28^=X^;pu-|{o%wwW)rkC(ENp*Eg+O z9P+S@|DRw*-sdB^F@K&)*S|`bC}>eC=eK*y>!w2XeHRt^&Y4K@XV`M?TfZV?#r=oV zb#7g#?cf!0(qa`^y27!7!^En@M&-bDH(kR;*S`Kr(f{2Ls#1JHe(lCnr@4%~ud1(_ zUy}9Yf5+e6xVzl~2OBR<4O3!R6k>MzL|Kked{fod$*Zpz#a@yve`))#L;vl&)#e5P zx~g6ab7Gk_^LuBQW&4<0R8&M~^BbPFsJ5M@WpM34$hwNZHXC}EmpL7~`!3_Vcz`!M z$Mp@no2Fl~W%A|#B?3@3o~~-gqzjJlP&+0=5Mz6%9g_hgSZI$ulM9%^?7$QZW<)wL z1%Vms9GC*Zj9-pS($i%fnasevFh?eTFr&`}D16wF37qk#0~JA3`#C`wi=3bezrYx7 z&QOsVFvcqw!^Q<+D#Z8)FcBkHs1(p->FM)bq3*ch3bjYa4Juy;V_bkSl-!|GB{0S@ Qccut%$biF1&4bAn06G)x!vFvP diff --git a/dist/extension/birb.js b/dist/extension/birb.js index 2eb3f95..4606bee 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -1869,7 +1869,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2026.1.10", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.10"); }, false), + new MenuItem("2026.1.18", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.18"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/extension/manifest.json b/dist/extension/manifest.json index 7a73455..5a87d8c 100644 --- a/dist/extension/manifest.json +++ b/dist/extension/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Pocket Bird", "description": "It's a pet bird in your browser, what more could you want?", - "version": "2026.1.10", + "version": "2026.1.18", "homepage_url": "https://idreesinc.com", "icons": { "48": "images/icons/transparent/48x48x1.png", diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index 09fa2bf..ac99d5c 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -1,7 +1,7 @@ const { Plugin, Notice } = require('obsidian'); module.exports = class PocketBird extends Plugin { onload() { - console.log("Loading Pocket Bird version 2026.1.10..."); + console.log("Loading Pocket Bird version 2026.1.18..."); const OBSIDIAN_PLUGIN = this; (function () { 'use strict'; @@ -1912,7 +1912,7 @@ module.exports = class PocketBird extends Plugin { insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2026.1.10", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.10"); }, false), + new MenuItem("2026.1.18", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.18"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/obsidian/manifest.json b/dist/obsidian/manifest.json index 0152ace..de3d1eb 100644 --- a/dist/obsidian/manifest.json +++ b/dist/obsidian/manifest.json @@ -1,7 +1,7 @@ { "id": "pocket-bird", "name": "Pocket Bird", - "version": "2026.1.10", + "version": "2026.1.18", "minAppVersion": "0.15.0", "description": "Add a pet bird to fly around your notes and keep you company!", "author": "Idrees Hassan", diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index 5d1d897..7db413a 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Pocket Bird // @namespace https://idreesinc.com -// @version 2026.1.10 +// @version 2026.1.18 // @description It's a pet bird in your browser, what more could you want? // @author Idrees // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js @@ -1874,7 +1874,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2026.1.10", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.10"); }, false), + new MenuItem("2026.1.18", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.18"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/web/birb.embed.js b/dist/web/birb.embed.js index 10ac911..48fb44a 100644 --- a/dist/web/birb.embed.js +++ b/dist/web/birb.embed.js @@ -1854,7 +1854,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2026.1.10", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.10"); }, false), + new MenuItem("2026.1.18", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.18"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/web/birb.js b/dist/web/birb.js index 10ac911..48fb44a 100644 --- a/dist/web/birb.js +++ b/dist/web/birb.js @@ -1854,7 +1854,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2026.1.10", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.10"); }, false), + new MenuItem("2026.1.18", () => { alert("Thank you for using Pocket Bird! You are on version: 2026.1.18"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/src/Frame.js b/src/Frame.js deleted file mode 100644 index f8c6ece..0000000 --- a/src/Frame.js +++ /dev/null @@ -1,76 +0,0 @@ -import { Directions } from './shared.js'; -import { Sprite, BirdType } from './sprites.js'; -import Layer from './layer.js'; - -class Frame { - - /** @type {{ [tag: string]: string[][] }} */ - #pixelsByTag = {}; - - /** - * @param {Layer[]} layers - */ - constructor(layers) { - /** @type {Set} */ - let tags = new Set(); - for (let layer of layers) { - tags.add(layer.tag); - } - tags.add("default"); - for (let tag of tags) { - let maxHeight = layers.reduce((max, layer) => Math.max(max, layer.pixels.length), 0); - if (layers[0].tag !== "default") { - throw new Error("First layer must have the 'default' tag"); - } - this.pixels = layers[0].pixels.map(row => row.slice()); - // Pad from top with transparent pixels - while (this.pixels.length < maxHeight) { - this.pixels.unshift(new Array(this.pixels[0].length).fill(Sprite.TRANSPARENT)); - } - // Combine layers - for (let i = 1; i < layers.length; i++) { - if (layers[i].tag === "default" || layers[i].tag === tag) { - let layerPixels = layers[i].pixels; - let topMargin = maxHeight - layerPixels.length; - for (let y = 0; y < layerPixels.length; y++) { - for (let x = 0; x < layerPixels[y].length; x++) { - this.pixels[y + topMargin][x] = layerPixels[y][x] !== Sprite.TRANSPARENT ? layerPixels[y][x] : this.pixels[y + topMargin][x]; - } - } - } - } - this.#pixelsByTag[tag] = this.pixels.map(row => row.slice()); - } - } - - /** - * @param {string} [tag] - * @returns {string[][]} - */ - getPixels(tag = "default") { - return this.#pixelsByTag[tag] ?? this.#pixelsByTag["default"]; - } - - /** - * @param {CanvasRenderingContext2D} ctx - * @param {BirdType} [species] - * @param {number} direction - * @param {number} canvasPixelSize - */ - draw(ctx, direction, canvasPixelSize, species) { - // Clear the canvas before drawing the new frame - ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); - - const pixels = this.getPixels(species?.tags[0]); - for (let y = 0; y < pixels.length; y++) { - const row = pixels[y]; - for (let x = 0; x < pixels[y].length; x++) { - const cell = direction === Directions.LEFT ? row[x] : row[pixels[y].length - x - 1]; - ctx.fillStyle = species?.colors[cell] ?? cell; - ctx.fillRect(x * canvasPixelSize, y * canvasPixelSize, canvasPixelSize, canvasPixelSize); - }; - }; - } -} - -export default Frame; \ No newline at end of file diff --git a/src/Layer.js b/src/Layer.js deleted file mode 100644 index cd33990..0000000 --- a/src/Layer.js +++ /dev/null @@ -1,12 +0,0 @@ -class Layer { - /** - * @param {string[][]} pixels - * @param {string} [tag] - */ - constructor(pixels, tag = "default") { - this.pixels = pixels; - this.tag = tag; - } -} - -export default Layer; \ No newline at end of file diff --git a/src/anim.js b/src/animation/anim.js similarity index 100% rename from src/anim.js rename to src/animation/anim.js diff --git a/src/frame.js b/src/animation/frame.js similarity index 98% rename from src/frame.js rename to src/animation/frame.js index f8c6ece..757619b 100644 --- a/src/frame.js +++ b/src/animation/frame.js @@ -1,4 +1,4 @@ -import { Directions } from './shared.js'; +import { Directions } from '../shared.js'; import { Sprite, BirdType } from './sprites.js'; import Layer from './layer.js'; diff --git a/src/layer.js b/src/animation/layer.js similarity index 100% rename from src/layer.js rename to src/animation/layer.js diff --git a/src/sprites.js b/src/animation/sprites.js similarity index 100% rename from src/sprites.js rename to src/animation/sprites.js diff --git a/src/application.js b/src/application.js index 396e7fb..6c710d7 100644 --- a/src/application.js +++ b/src/application.js @@ -1,6 +1,6 @@ -import Frame from './frame.js'; -import Layer from './layer.js'; -import Anim from './anim.js'; +import Frame from './animation/frame.js'; +import Layer from './animation/layer.js'; +import Anim from './animation/anim.js'; import { Birb, Animations } from './birb.js'; import { Birdsong } from './sound.js'; import { Context, ObsidianContext } from './context.js'; @@ -26,7 +26,7 @@ import { Sprite, SPRITE_SHEET_COLOR_MAP, SPECIES -} from './sprites.js'; +} from './animation/sprites.js'; import { StickyNote, createNewStickyNote, diff --git a/src/birb.js b/src/birb.js index a2baeb6..a7f6843 100644 --- a/src/birb.js +++ b/src/birb.js @@ -1,8 +1,8 @@ import { Directions, getLayer, getWindowHeight, getFixedWindowHeight } from './shared.js'; -import Layer from './layer.js'; -import Frame from './frame.js'; -import Anim from './anim.js'; -import { BirdType } from './sprites.js'; +import Layer from './animation/layer.js'; +import Frame from './animation/frame.js'; +import Anim from './animation/anim.js'; +import { BirdType } from './animation/sprites.js'; /** * @typedef {keyof typeof Animations} AnimationType