Module

Puregrain.Internal.Cells

Package
purescript-puregrain
Repository
roman-mkh/puregrain

CellPalette's inside, and what is measured along it, for Puregrain.Cells and its tests. Internal: may change without notice. Puregrain.Cells re-exports the type, opaquely, with its constructors.

#CellPalette Source

newtype CellPalette

The colors one cell may use: one color, or two that dithering mixes. Build it with singleColor or colorPair. The order of two colors doesn't change which cells choose them, nor what nearestInCell gives; with orderedInCell it sets the pattern's direction.

Constructors

#cellShare Source

cellShare :: CellPalette -> RGB -> Number

How far along the line from the cell's first color to its second the pixel's nearest point lies, from 0 to 1; 0 for a single color.

#cellTone Source

cellTone :: CellPalette -> RGB -> RGB

A pixel's tone in its cell: how far along the line from the first color to the second its nearest point lies, from 0 to 1, times 255, the same in every channel (the cell mixes the two colors as a whole); 0 for a single color. The direction doesn't matter to a method by tone: its table is symmetric, so a share and its complement pick the same row.

  • CellPalette: the cell's colors, in light when the dithering has a curve.
  • RGB: the original pixel, in light likewise.

#raisedInCell Source

raisedInCell :: Number -> CellPalette -> RGB -> RGB

nearestInCell's decision with its cut raised: the second color where the pixel's share of the way to it is above one half plus the raise, else the first; a single color always.

  • Number: the raise, a fraction of the way between the two colors.
  • CellPalette: the cell's colors.
  • RGB: the corrected value.