From cb2898f6a651d7d8194dee9707fe4a34ab514e55 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 26 Nov 2022 08:07:57 -0800 Subject: [PATCH] fix red/blue palette mixup --- dither-image.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dither-image.js b/dither-image.js index eeb0f7a..040ed5e 100644 --- a/dither-image.js +++ b/dither-image.js @@ -28,9 +28,9 @@ class RGB { } static fromHex(val) { - let r = val & 0xff; - let g = (val >> 8) & 0xff; - let b = (val >> 16) & 0xff; + let r = (val >>> 16) & 0xff; + let g = (val >>> 8) & 0xff; + let b = val & 0xff; return new RGB(r,g,b); } @@ -618,7 +618,7 @@ async function convert(source, nbits) { // Start with all colors usable with regular CTIA modes // (not the 16-luminance special mode on GTIA) let allColors = []; - for (let i = 0; i < 0xff; i += 2) { + for (let i = 0; i < 256; i += 2) { allColors.push(i); }