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
distance_calculator()
View Source
distance_calculator() :: module() | {module(), Keyword.t()} | distance_fun()
distance_calculator() :: module() | {module(), Keyword.t()} | distance_fun()
distance_fun()
View Source
distance_fun() :: (Tint.color(), Tint.color() -> number())
distance_fun() :: (Tint.color(), Tint.color() -> number())
Link to this section Functions
distance(color, other_color, distance_calculator)
View Source
distance(Tint.color(), Tint.color(), distance_calculator()) :: float()
distance(Tint.color(), Tint.color(), distance_calculator()) :: float()
Calculate the distance of two colors using the given distance calculator.
Caches the results if Tint.DistanceCache
is running.
nearest_color(color, palette, distance_calculator)
View Source
nearest_color(Tint.color(), [Tint.color()], distance_calculator()) ::
nil | Tint.color()
nearest_color(Tint.color(), [Tint.color()], distance_calculator()) :: nil | Tint.color()
Gets the nearest color from the specified palette using the given distance calculator.
nearest_colors(color, palette, n, distance_calculator)
View Source
nearest_colors(
Tint.color(),
[Tint.color()],
non_neg_integer(),
distance_calculator()
) :: [Tint.color()]
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
distance(color, other_color, opts)
View Source
distance(
color :: Tint.color(),
other_color :: Tint.color(),
opts :: Keyword.t()
) :: number()
distance( color :: Tint.color(), other_color :: Tint.color(), opts :: Keyword.t() ) :: number()
Calculate the distance of two colors using the given options.