Pote.Format behaviour (Pote v1.0.0)

Copy Markdown View Source

Behaviour for colour format handlers.

Each colour format module (ANSI, Hex, RGB, ARGB, HSL, HSV, CMYK, XTerm256, Atom) implements this behaviour to provide a consistent interface for colour parsing, validation, and conversion to all supported colour spaces.

See Pote.Format.RGB, Pote.Format.Hex, Pote.Format.HSL, etc. for the built-in implementations.

Summary

Callbacks

from_rgb(tuple)

@callback from_rgb({integer(), integer(), integer()}) :: any()

info(any)

@callback info(any()) :: map()

name(any)

@callback name(any()) :: String.t() | nil

parse(any)

@callback parse(any()) :: {:ok, any()} | :error

to_argb(any)

@callback to_argb(any()) :: {integer(), integer(), integer(), integer()}

to_cmyk(any)

@callback to_cmyk(any()) :: {float(), float(), float(), float()}

to_hex(any)

@callback to_hex(any()) :: String.t()

to_hsl(any)

@callback to_hsl(any()) :: {float(), float(), float()}

to_hsv(any)

@callback to_hsv(any()) :: {float(), float(), float()}

to_rgb(any)

@callback to_rgb(any()) :: {integer(), integer(), integer()}

to_xterm256(any)

@callback to_xterm256(any()) :: non_neg_integer()

valid?(any)

@callback valid?(any()) :: boolean()