@city41/gba-convertpng 0.0.29 → 0.0.30

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.
@@ -101,6 +101,10 @@ function padPalette(palette) {
101
101
  }
102
102
  async function processBackground(bg) {
103
103
  let canvas = await (0, canvas_1.createCanvasFromPath)(bg.file);
104
+ const colorCount = (0, palette_1.extractPalette)(canvas, false).length;
105
+ if (bg.forcePalette && colorCount > 15) {
106
+ throw new Error(`Background with forcedPalette set, but image has ${colorCount} colors, ${bg.file}`);
107
+ }
104
108
  if (typeof bg.reduceColors === "undefined" || bg.reduceColors === true) {
105
109
  canvas = await (0, canvas_1.reduceColors)(canvas, 16);
106
110
  }
package/dist/canvas.js CHANGED
@@ -108,10 +108,12 @@ function findNearestColor(pixel, palette) {
108
108
  b: pixel[2],
109
109
  };
110
110
  const nearestResult = (0, nearest_color_1.default)(pixelInput, colorsInput);
111
- pixel[0] = nearestResult.rgb.r;
112
- pixel[1] = nearestResult.rgb.g;
113
- pixel[2] = nearestResult.rgb.b;
114
- return pixel;
111
+ const nearestPixel = new Array(4);
112
+ nearestPixel[0] = nearestResult.rgb.r;
113
+ nearestPixel[1] = nearestResult.rgb.g;
114
+ nearestPixel[2] = nearestResult.rgb.b;
115
+ nearestPixel[3] = 255;
116
+ return Uint8ClampedArray.from(nearestPixel);
115
117
  }
116
118
  function isMagenta(pixel) {
117
119
  return pixel[0] === 255 && pixel[1] === 0 && pixel[2] === 255;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@city41/gba-convertpng",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "Converts png images to GBA tile format",
5
5
  "main": "index.js",
6
6
  "repository": "github.com/city41/gba-convertpng",