View Source Tint.Lab (Tint v1.3.0)

A color in the CIELAB colorspace.

Summary

Functions

Calculates the distance of two colors using the CIEDE2000 algorithm. See Tint.Distance.CIEDE2000 for more details.

Converts a tuple containing lightness, a and b into Tint.Lab struct.

Gets the nearest color from the given palette using the CIEDE2000 color distance algorithm.

Gets the n nearest colors from the given palette using the CIEDE2000 color distance algorithm.

Builds a new Lab color using the lightness, a and b color channels.

Converts a Lab color into a tuple containing the lightness, a and b channels.

Types

@type t() :: %Tint.Lab{a: float(), b: float(), lightness: float()}

Functions

Link to this function

ciede2000_distance(color, other_color, opts \\ [])

View Source (since 1.0.0)
@spec ciede2000_distance(Tint.color(), Tint.color(), Keyword.t()) :: float()

Calculates the distance of two colors using the CIEDE2000 algorithm. See Tint.Distance.CIEDE2000 for more details.

Link to this function

from_tuple(arg)

View Source (since 1.0.0)
@spec from_tuple(
  {number() | String.t(), number() | String.t(), number() | String.t()}
) :: t()

Converts a tuple containing lightness, a and b into Tint.Lab struct.

Link to this function

nearest_color(color, palette, distance_algorithm \\ Distance.CIEDE2000)

View Source (since 1.0.0)
@spec nearest_color(
  Tint.color(),
  [Tint.color()],
  Tint.Distance.distance_algorithm()
) :: nil | Tint.color()

Gets the nearest color from the given palette using the CIEDE2000 color distance algorithm.

Options

  • :weights - A tuple defining the weights for the LCh color channels. Defaults to {1, 1, 1}.
Link to this function

nearest_colors(color, palette, n, distance_algorithm \\ Distance.CIEDE2000)

View Source (since 1.0.0)

Gets the n nearest colors from the given palette using the CIEDE2000 color distance algorithm.

Link to this function

new(lightness, a, b)

View Source (since 1.0.0)
@spec new(number() | String.t(), number() | String.t(), number() | String.t()) :: t()

Builds a new Lab color using the lightness, a and b color channels.

Link to this function

to_tuple(color)

View Source (since 1.0.0)
@spec to_tuple(t()) :: {float(), float(), float()}

Converts a Lab color into a tuple containing the lightness, a and b channels.