I don't know what the context of the original post is, but I implemented this algo in Canvas/JS some time ago https://tgiachett.github.io/canvas-floyd-steinberg-dither/
It's a little rough around the edges, but I think the code is still readable.
thanks for the link :)
I will check that. I certainly will try this using processing. There is already a video on youtube which details how to do this.