pub fn effect() -> Vec<u8> ⓘExpand description
An implementation of the Floyd-Steinberg dithering algorithm. When a pixel’s error is calculated, the error is diffused down to other pixels with the following pattern (X is the current pixel, the numbers are fractions of 16):
|- - -|- - -|- - -|
| | x | 7 |
|- - -|- - -|- - -|
| 3 | 5 | 1 |
|- - -|- - -|- - -|The algorithm does this by storing the diffused error in a one-dimensional array with the size equal to the width of the image. Due to the divisor being 16, which is a multiple of two, bit-shifting can be used for better performance.