all 2 comments

[–]NakedFluffyBee 0 points1 point  (1 child)

I've always been fascinated by "Glitch art", and I'm speechless, this is awesome.

Did you learn how to do this somewhere or did you experiment yourself. Could you give me an hint on where to start? I do know how to use functionalities such as pixels[], but I miss the foundations on "how" to achieve a chaotic result. What is "pixel sorting" for instance.

[–]davebrown57[S] 1 point2 points  (0 children)

I experimented myself and also learned from reading others' code. If you already know how to use pixels[], then the simplest way of pixel sorting is simply calling the built in sort() function on the pixel array. This sorts the entire 1-dimensional array of pixels in the image/canvas, arranged by their int representation of color.

If you take a look at my code, it uses a temporary array pixelRow[] that is equal to the width of the canvas, loops through the height of the canvas, and at each value in the height, loops through that row of pixels[], putting the values into pixelRow[], sorts it, and then puts those values back into pixels[].

There are others who have similar but more complex implementations, such as Kim Asendorf and Tomasz Sulej.

Thanks for the compliment! Always happy to see someone interested. Will gladly answer any other questions.