@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.
- package/dist/background.js +4 -0
- package/dist/canvas.js +6 -4
- package/package.json +1 -1
package/dist/background.js
CHANGED
|
@@ -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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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;
|