Palettes that can be plugged into the tiny pockets press
https://git.lewismoten.com/tiny-pockets-press/dither-lib/raw/branch/main/index.html
- JavaScript 100%
| amber2 | ||
| ansi16 | ||
| atari400 | ||
| atari400base | ||
| c64 | ||
| cga0 | ||
| cga1 | ||
| cmyk-overprint | ||
| colors4 | ||
| colors8 | ||
| colors16 | ||
| colors27 | ||
| colors32 | ||
| colors64 | ||
| colors125 | ||
| colors128 | ||
| colors256 | ||
| ega16 | ||
| eink2 | ||
| eink3red | ||
| eink3yellow | ||
| eink4 | ||
| gray2 | ||
| gray4 | ||
| gray8 | ||
| gray16 | ||
| gray32 | ||
| gray64 | ||
| gray128 | ||
| gray256 | ||
| green2 | ||
| lcd4 | ||
| websafe | ||
| windows16 | ||
| xterm256 | ||
| .gitignore | ||
| library.js | ||
| LICENSE.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Palette Plugins
This repository contains JavaScript palette plugins and a palette library registry.
Each palette is a standalone .js file that registers itself at runtime.
The library registry is defined in library.js, which calls TPP.registerPaletteLibrary(...) with the list of available palettes and their retrieval URLs.
Library registration looks like this:
(function () {
const registerPaletteLibrary =
window.TPP && window.TPP.registerPaletteLibrary;
if (typeof registerPaletteLibrary !== "function") return;
registerPaletteLibrary({
palettes: [
{
id: "sample4",
name: "Sample 4-Color",
url: "https://git.lewismoten.com/tiny-pockets-press/palette-lib/sample4.js",
colorCount: 4,
description:
"A simple 4-color sample palette for demonstrating the plugin format.",
},
],
});
})();
Palette plugins should call TPP.registerPalette(...):
(function () {
const name = "Sample 4-Color";
const baseMessage = `Palette "${name}" could not register.`;
const logError = function (message, err) {
if (typeof console !== "undefined" && typeof console.error === "function") {
if (arguments.length > 1) console.error(message, err);
else console.error(message);
}
};
const registerPalette = window.TPP && window.TPP.registerPalette;
if (typeof registerPalette !== "function") {
logError(`${baseMessage} TPP.registerPalette not found.`);
return;
}
try {
registerPalette({
schemaVersion: 1,
id: "sample4",
name: name,
description:
"A simple 4-color sample palette for demonstrating the plugin format.",
colorNumbers: [0, 1, 2, 3],
colorNames: ["black", "red", "green", "yellow"],
colors: ["#000000", "#ff0000", "#00ff00", "#ffff00"],
});
} catch (err) {
logError(baseMessage, err);
}
})();
Runtime API:
TPP.registerPalette(plugin)registers a palette plugin.TPP.registerPaletteLibrary({ palettes })registers the available palette library for lazy loading.
Included palettes include hardware-inspired sets, grayscale ramps, e-paper
variants, and print-style options such as cmyk-overprint, which matches the
CMYK overprint palette used by the dither demo.