implement dithering. thanks @PAEz.