mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-26 04:07:24 +00:00
Move sprite related files to separate folder
This commit is contained in:
BIN
dist/extension.zip
vendored
BIN
dist/extension.zip
vendored
Binary file not shown.
2
dist/extension/birb.js
vendored
2
dist/extension/birb.js
vendored
@@ -1869,7 +1869,7 @@
|
|||||||
insertModal(`${birdBirb()} Mode`, message);
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
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");
|
const styleElement = document.createElement("style");
|
||||||
|
|||||||
2
dist/extension/manifest.json
vendored
2
dist/extension/manifest.json
vendored
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Pocket Bird",
|
"name": "Pocket Bird",
|
||||||
"description": "It's a pet bird in your browser, what more could you want?",
|
"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",
|
"homepage_url": "https://idreesinc.com",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "images/icons/transparent/48x48x1.png",
|
"48": "images/icons/transparent/48x48x1.png",
|
||||||
|
|||||||
4
dist/obsidian/main.js
vendored
4
dist/obsidian/main.js
vendored
@@ -1,7 +1,7 @@
|
|||||||
const { Plugin, Notice } = require('obsidian');
|
const { Plugin, Notice } = require('obsidian');
|
||||||
module.exports = class PocketBird extends Plugin {
|
module.exports = class PocketBird extends Plugin {
|
||||||
onload() {
|
onload() {
|
||||||
console.log("Loading Pocket Bird version 2026.1.10...");
|
console.log("Loading Pocket Bird version 2026.1.18...");
|
||||||
const OBSIDIAN_PLUGIN = this;
|
const OBSIDIAN_PLUGIN = this;
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -1912,7 +1912,7 @@ module.exports = class PocketBird extends Plugin {
|
|||||||
insertModal(`${birdBirb()} Mode`, message);
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
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");
|
const styleElement = document.createElement("style");
|
||||||
|
|||||||
2
dist/obsidian/manifest.json
vendored
2
dist/obsidian/manifest.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "pocket-bird",
|
"id": "pocket-bird",
|
||||||
"name": "Pocket Bird",
|
"name": "Pocket Bird",
|
||||||
"version": "2026.1.10",
|
"version": "2026.1.18",
|
||||||
"minAppVersion": "0.15.0",
|
"minAppVersion": "0.15.0",
|
||||||
"description": "Add a pet bird to fly around your notes and keep you company!",
|
"description": "Add a pet bird to fly around your notes and keep you company!",
|
||||||
"author": "Idrees Hassan",
|
"author": "Idrees Hassan",
|
||||||
|
|||||||
4
dist/userscript/birb.user.js
vendored
4
dist/userscript/birb.user.js
vendored
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Pocket Bird
|
// @name Pocket Bird
|
||||||
// @namespace https://idreesinc.com
|
// @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?
|
// @description It's a pet bird in your browser, what more could you want?
|
||||||
// @author Idrees
|
// @author Idrees
|
||||||
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js
|
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js
|
||||||
@@ -1874,7 +1874,7 @@
|
|||||||
insertModal(`${birdBirb()} Mode`, message);
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
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");
|
const styleElement = document.createElement("style");
|
||||||
|
|||||||
2
dist/web/birb.embed.js
vendored
2
dist/web/birb.embed.js
vendored
@@ -1854,7 +1854,7 @@
|
|||||||
insertModal(`${birdBirb()} Mode`, message);
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
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");
|
const styleElement = document.createElement("style");
|
||||||
|
|||||||
2
dist/web/birb.js
vendored
2
dist/web/birb.js
vendored
@@ -1854,7 +1854,7 @@
|
|||||||
insertModal(`${birdBirb()} Mode`, message);
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
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");
|
const styleElement = document.createElement("style");
|
||||||
|
|||||||
76
src/Frame.js
76
src/Frame.js
@@ -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<string>} */
|
|
||||||
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;
|
|
||||||
12
src/Layer.js
12
src/Layer.js
@@ -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;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Directions } from './shared.js';
|
import { Directions } from '../shared.js';
|
||||||
import { Sprite, BirdType } from './sprites.js';
|
import { Sprite, BirdType } from './sprites.js';
|
||||||
import Layer from './layer.js';
|
import Layer from './layer.js';
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import Frame from './frame.js';
|
import Frame from './animation/frame.js';
|
||||||
import Layer from './layer.js';
|
import Layer from './animation/layer.js';
|
||||||
import Anim from './anim.js';
|
import Anim from './animation/anim.js';
|
||||||
import { Birb, Animations } from './birb.js';
|
import { Birb, Animations } from './birb.js';
|
||||||
import { Birdsong } from './sound.js';
|
import { Birdsong } from './sound.js';
|
||||||
import { Context, ObsidianContext } from './context.js';
|
import { Context, ObsidianContext } from './context.js';
|
||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
Sprite,
|
Sprite,
|
||||||
SPRITE_SHEET_COLOR_MAP,
|
SPRITE_SHEET_COLOR_MAP,
|
||||||
SPECIES
|
SPECIES
|
||||||
} from './sprites.js';
|
} from './animation/sprites.js';
|
||||||
import {
|
import {
|
||||||
StickyNote,
|
StickyNote,
|
||||||
createNewStickyNote,
|
createNewStickyNote,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Directions, getLayer, getWindowHeight, getFixedWindowHeight } from './shared.js';
|
import { Directions, getLayer, getWindowHeight, getFixedWindowHeight } from './shared.js';
|
||||||
import Layer from './layer.js';
|
import Layer from './animation/layer.js';
|
||||||
import Frame from './frame.js';
|
import Frame from './animation/frame.js';
|
||||||
import Anim from './anim.js';
|
import Anim from './animation/anim.js';
|
||||||
import { BirdType } from './sprites.js';
|
import { BirdType } from './animation/sprites.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {keyof typeof Animations} AnimationType
|
* @typedef {keyof typeof Animations} AnimationType
|
||||||
|
|||||||
Reference in New Issue
Block a user