Notes
Oh this was a lot of fun to do! Followed the prompt of #genuary2023 day 3: Glitch Art.
How it works:
- find image from unsplash: thank you Aiony
Haust on Unsplash
- preload image and draw onto canvas on setup
- on every cycle...
- -- loop through all every pixel row on y-axis, toss a dice
- ---- if it falls within the probability, glitch the row!
- -- do a whole image glitch once in a while too
- -- pick randomly from a list of blend modes to make the glitchs look different from one another
A surprising learning is how tricky it is to get the probabilities right. I wanted to make the whole picture glitch rarer than the row-specific glitch, so you'd think that the probability should be smaller, right? Nope... turns out I had to multiply the probability for the whole picture glitch to make it appear often enough (and still less often than the smaller row-specific glitch). Why? Because there are 400 pixels on the y-axis, and a probability of 0.001 for each of them to glitch already creates the effect I wanted. But if I used 0.001 (or something even smaller) for the whole image glitch, then it comes waaaay to infrequent because every cycle this dice throw happens only once (versus 400 times).
Created with p5.js, a JavaScript library for creative coding.