can you see the moment i gave up. no you can't because i gave up after going back to round 1 LMAO
MATHRANDOM HATES MEEEEE sorry. it's a mess. cbf to beautify
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
const upload = document.getElementById("upload");
let img = new Image();
upload.addEventListener("change", (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = function(event) {
img.onload = function() {
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
}
img.src = event.target.result;
}
reader.readAsDataURL(file);
});
function applyRedo() {
ctx.drawImage(img, 0, 0);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
let r = data[i], // red
g = data[i + 1], // green
b = data[i + 2]; // blue
data[i] = Math.min(Math.round((Math.random() * 0.799) * r + (Math.random() * 0.799) * g + 0.189 * b), 255);
data[i + 1] = Math.min(Math.round((Math.random() * 0.799) * r + (Math.random() * 0.799) * g + 0.168 * b), 255);
data[i + 2] = Math.min(Math.round(Math.random() * 0.799) * r + 0.534 * g + 0.131 * b), 255);
}
ctx.putImageData(imageData, 0, 0);
}
function downloadImage() {
const link = document.createElement("a");
link.download = "edited-photo.png";
link.href = canvas.toDataURL("image/png");
link.click();
}
email me @ mitzi@scary.dog to brag that you could do what i could not. if you can figure out what i was doing. maybe i don't even know what i was doing. my hp is at 10 and every person who does the cool rng colour filter will get both a cookie and will knock off 10000000 million hp from me.
(i'm just being silly now but you can email me regardless!!! i love emails!!!) (btw i'm still loving wwoctober!! even if i beefed it today <3
<--