Puregrain.Internal.Row
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
One row of the diffusion: the step for each pixel, then handing the row's queues over to the rows below. Internal: may change without notice.
A row runs left to right, or right to left under serpentine scanning
(Puregrain.Internal.Params.rightToLeft). The queues hold their error
fractions in the order of the row that produced them, so a queue for a
row that runs the other way is reversed when it's handed over
(handOver); with alternating rows, that's every queue for a row an
odd number of rows below.
#stepRow Source
stepRow :: forall f a. Fifo f => Ring a => CompiledParams a -> CompiledQuantize a -> DitherState f a -> Array a -> Either String (Tuple (DitherState f a) (Array a))Dithers one row and returns the state for the next one. States are plain immutable values: stepping from an old one again (an undo, say) redoes that row's work, the queues' list reversals included, and no more.
Every row must be as long as the first one. A row of a different
length is a caller's bug: Left with a message naming the row,
rather than reading past the queued error or leaving it misaligned
for the rows below. The state isn't touched, so the caller can retry.
The quantizer comes resolved (Puregrain.Internal.Quantize.compileQuantize),
once per run by the caller, not once per row or pixel. The row's
direction comes from the scan and the row's index, state.nextRow.
#orStop Source
orStop :: forall a. Either String a -> aThe other half of stepRow's contract: its Left (a row of a
different length, a caller's bug) becomes a stop with the same
message. For the drivers whose result type can't carry an error:
ditherImage and ditherRows (Puregrain.Internal.Image), and
ditherCells and ditherBands (Puregrain.Cells).
#initBuilding Source
initBuilding :: forall f a. Fifo f => Ring a => CompiledKernel a -> Array (RowLayer f a)#commitBuilding Source
commitBuilding :: forall f a. Fifo f => Ring a => CompiledKernel a -> (Int -> Boolean) -> Array (RowLayer f a) -> Array (DelayLine f a) -> Array (DelayLine f a)Hands a finished row's queues over to the rows below: each later
row's layer joins the end of its delay line. turns dy says whether
the row dy below runs the other way.
- 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