Linocut.Quantise (Linocut v0.2.2)

Copy Markdown View Source

A picture reduced to a small palette.

{reduced, palette} = Linocut.Quantise.reduce(raster, 16)

The palette is chosen by median cut over the picture's opaque pixels and every pixel is then moved to its nearest entry. A pixel whose alpha is under the threshold stays clear and takes no palette entry.

Summary

Functions

The entry of palette closest to colour.

At most count colours chosen from raster's opaque pixels, darkest first.

raster with at most count colours, and the palette it was given.

raster with every opaque pixel moved to its nearest entry in palette.

Types

colour()

@type colour() :: {0..255, 0..255, 0..255}

Functions

nearest(palette, arg)

@spec nearest([colour()], colour()) :: colour()

The entry of palette closest to colour.

palette(raster, count, opts \\ [])

@spec palette(FrenchCurve.Raster.t(), pos_integer(), keyword()) :: [colour()]

At most count colours chosen from raster's opaque pixels, darkest first.

Options

  • :alpha — the alpha at or above which a pixel counts as opaque. Default 128

reduce(raster, count, opts \\ [])

raster with at most count colours, and the palette it was given.

Options

  • :alpha — the alpha at or above which a pixel counts as opaque. Default 128

to_palette(raster, palette, opts)

@spec to_palette(FrenchCurve.Raster.t(), [colour()], keyword()) ::
  FrenchCurve.Raster.t()

raster with every opaque pixel moved to its nearest entry in palette.

Options

  • :alpha — the alpha at or above which a pixel counts as opaque. Default 128