Tint v1.0.0-rc.0 Tint.Distance behaviour View Source

Main module providing color distance calculations.

Link to this section Summary

Functions

Calculate the distance of two colors using the given distance calculator. Caches the results if Tint.DistanceCache is running.

Gets the nearest color from the specified palette using the given distance calculator.

Gets the nearest n colors from the specified palette using the given distance calculator.

Callbacks

Calculate the distance of two colors using the given options.

Link to this section Types

Link to this type

distance_calculator() View Source
distance_calculator() :: module() | {module(), Keyword.t()} | distance_fun()

Link to this type

distance_fun() View Source
distance_fun() :: (Tint.color(), Tint.color() -> number())

Link to this section Functions

Link to this function

distance(color, other_color, distance_calculator) View Source

Calculate the distance of two colors using the given distance calculator. Caches the results if Tint.DistanceCache is running.

Link to this function

nearest_color(color, palette, distance_calculator) View Source
nearest_color(Tint.color(), [Tint.color()], distance_calculator()) ::
  nil | Tint.color()

Gets the nearest color from the specified palette using the given distance calculator.

Link to this function

nearest_colors(color, palette, n, distance_calculator) View Source
nearest_colors(
  Tint.color(),
  [Tint.color()],
  non_neg_integer(),
  distance_calculator()
) :: [Tint.color()]

Gets the nearest n colors from the specified palette using the given distance calculator.

Link to this section Callbacks

Link to this callback

distance(color, other_color, opts) View Source
distance(
  color :: Tint.color(),
  other_color :: Tint.color(),
  opts :: Keyword.t()
) :: number()

Calculate the distance of two colors using the given options.