Module

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.

#stepRow Source

stepRow :: forall f a. Fifo f => Ring a => Scalable a => CompiledKernel -> Quantizer 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.quantizerFor), once per run by the caller, not once per row or pixel.

#orStop Source

orStop :: forall a. Either String a -> a

The 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 -> Array (RowLayer f a)

#commitBuilding Source

commitBuilding :: forall f a. Fifo f => Ring a => CompiledKernel -> Array (RowLayer f a) -> Array (DelayLine f a) -> Array (DelayLine f a)