Puregrain.Internal.Noise
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
White noise for threshold modulation (Zhou–Fang's method): a number from 0 to 127 for each pixel position, from a hash of the position, so that it doesn't depend on the order the pixels are visited in (rows streamed, the stepper, cells, serpentine scanning) and is the same on every engine. Internal: may change without notice.
#noise Source
noise :: Int -> Int -> IntThe noise at a position: 0 to 127, like C's rand() % 128 in Zhou
and Fang's formula, whose generator they leave to "the program
library supplied with any programming languages" (their footnote 3).
A fixed seed, so the same picture dithers alike every time.
Int,Int: the column and the row, from the image's top-left.
#imul Source
imul :: Int -> Int -> Int32-bit multiplication, as JavaScript's Math.imul, exactly: from
16-bit halves, so that no product exceeds 2^53. PureScript's own *
on Int compiles to a * b | 0, whose product loses its low bits
once it passes 2^53 (the same on every engine, but not the 32-bit
product a hash needs).
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Gamma - Puregrain.
Internal. Cells - Puregrain.
Internal. Exact - Puregrain.
Internal. Fifo - Puregrain.
Internal. Gamma - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Noise - Puregrain.
Internal. Ostromoukhov - Puregrain.
Internal. Params - Puregrain.
Internal. Quantize - Puregrain.
Internal. Row - Puregrain.
Internal. SelfCheck - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Internal. WeightsByTone - Puregrain.
Internal. ZhouFang - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize - Puregrain.
SelfCheck