@city41/gba-convertpng 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/background.js +13 -6
- package/dist/main.js +3 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/background.js
CHANGED
|
@@ -110,12 +110,19 @@ async function processBackground(bg) {
|
|
|
110
110
|
const tilePalette = [];
|
|
111
111
|
let palettes = [];
|
|
112
112
|
// first, determine the palettes
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
if (bg.forcePalette) {
|
|
114
|
+
const forcedPaletteCanvas = await (0, canvas_1.createCanvasFromPath)(bg.forcePalette);
|
|
115
|
+
canvas = await (0, canvas_1.forceCanvasToPalette)(canvas, forcedPaletteCanvas);
|
|
116
|
+
palettes.push((0, palette_1.getForcedPalette)(forcedPaletteCanvas));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
for (let y = 0; y < canvas.height; y += 8) {
|
|
120
|
+
for (let x = 0; x < canvas.width; x += 8) {
|
|
121
|
+
const rawTile = Array.from(ctx.getImageData(x, y, 8, 8).data);
|
|
122
|
+
const data15 = convertTileTo15Bit(rawTile);
|
|
123
|
+
const palette = (0, palette_1.extractPalette15)(data15, false);
|
|
124
|
+
palettes = combinePalettes(palettes.concat([palette]));
|
|
125
|
+
}
|
|
119
126
|
}
|
|
120
127
|
}
|
|
121
128
|
// now with palettes in hand, do the rest
|
package/dist/main.js
CHANGED
|
@@ -81,6 +81,9 @@ function hydrateJsonSpec(jsonSpecPath) {
|
|
|
81
81
|
return {
|
|
82
82
|
...bg,
|
|
83
83
|
file: path.resolve(rootDir, bg.file),
|
|
84
|
+
forcePalette: bg.forcePalette
|
|
85
|
+
? path.resolve(rootDir, bg.forcePalette)
|
|
86
|
+
: undefined,
|
|
84
87
|
};
|
|
85
88
|
}),
|
|
86
89
|
bitmaps: (initialSpec.bitmaps ?? []).map((bmp) => {
|
package/dist/types.d.ts
CHANGED