From 97465b0aac135b8e2c402ac726cad3110b55987d Mon Sep 17 00:00:00 2001 From: Lily <56913305+Memez4Life7@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:18:52 +0100 Subject: [PATCH] messed up again --- hazy.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hazy.js b/hazy.js index e41fbcf..da3557e 100644 --- a/hazy.js +++ b/hazy.js @@ -185,6 +185,24 @@ } } + //creates a list of rgb values from image data + const buildRgb = (imageData) => { + const rgbValues = []; + // note that we are loopin every 4! + // for every Red, Green, Blue and Alpha + for (let i = 0; i < imageData.length; i += 4) { + const rgb = { + r: imageData[i], + g: imageData[i + 1], + b: imageData[i + 2], + }; + + rgbValues.push(rgb); + } + + return rgbValues; + }; + //converts RGB to Hex function rgbToHex(r, g, b) { return "#" + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');