From 092b7f3c39da6d283ec3202af614e420630f3d76 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 24 May 2024 21:17:43 +0200 Subject: [PATCH] Update script.js --- image_to_tellraw/script.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/image_to_tellraw/script.js b/image_to_tellraw/script.js index 9940049..b4264a0 100644 --- a/image_to_tellraw/script.js +++ b/image_to_tellraw/script.js @@ -30,20 +30,29 @@ const textArea = document.getElementById('textArea'); const tellrawParts = []; let row = []; + let logRow = []; + let logRowParts = []; pixels.forEach((pixel, index) => { const { red, green, blue, alpha } = pixel; - const color = `#${red.toString(16).padStart(2, '0')}${green.toString(16).padStart(2, '0')}${blue.toString(16).padStart(2, '0')}`; + const color = `${red.toString(16).padStart(2, '0')}${green.toString(16).padStart(2, '0')}${blue.toString(16).padStart(2, '0')}`; if (alpha >= 128) { - row.push(`{"color": "${color}", "text": "█"}`); + row.push(`{"color": "#${color}", "text": "█"}`); + logRow.push(color); } else { row.push(`" "`); + logRow.push(' '); } if ((index + 1) % img.width === 0) { tellrawParts.push(`[${row.join(', ')}]`); + console.log(JSON.stringify(logRow)); + logRowParts.push(logRow); row = []; + logRow = []; } }); + console.log(JSON.stringify(logRowParts,null,2)); + const tellrawCommand = `tellraw @a [\n ${tellrawParts.join(', "\\n",\n ')}\n]`; textArea.value = tellrawCommand;