@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.
@@ -110,12 +110,19 @@ async function processBackground(bg) {
110
110
  const tilePalette = [];
111
111
  let palettes = [];
112
112
  // first, determine the palettes
113
- for (let y = 0; y < canvas.height; y += 8) {
114
- for (let x = 0; x < canvas.width; x += 8) {
115
- const rawTile = Array.from(ctx.getImageData(x, y, 8, 8).data);
116
- const data15 = convertTileTo15Bit(rawTile);
117
- const palette = (0, palette_1.extractPalette15)(data15, false);
118
- palettes = combinePalettes(palettes.concat([palette]));
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
@@ -21,6 +21,7 @@ export type BackgroundSpec = {
21
21
  trimPalette?: boolean;
22
22
  transparentColor?: number;
23
23
  reduceColors?: boolean;
24
+ forcePalette?: string;
24
25
  };
25
26
  export type BitmapSpec = {
26
27
  file: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@city41/gba-convertpng",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "Converts png images to GBA tile format",
5
5
  "main": "index.js",
6
6
  "repository": "github.com/city41/gba-convertpng",