The 8 by 8 Bayer matrix behind ordered dithering, as a threshold from 0 to 1 for any pixel. Compare a brightness with it to decide whether that pixel is on.
npx shadcn@latest add https://mizzle.saddy.me/r/bayer.jsonSign in or get a license at mizzle to see its source and install it.