View Source Colorex.Palette (Colorex v1.0.0)

Functions for working with or generating palettes of colors.

Summary

Functions

Returns analogous colors for the input color

Returns n color(s) between the input colors

Returns the complement of a color in HSL colorspace.

Displays a list of color palettes

Generates N color palettes.

Returns tetradic colors for the input color

Returns triadic colors for the input color

Functions

analogous(color, degrees \\ 30)

@spec analogous(color :: Colorex.Colorex.color(), degrees :: pos_integer()) ::
  {Colorex.color(), Colorex.color()}

Returns analogous colors for the input color

returns a tuple of two colors that are N degrees(default 30°) away

## Example:

  iex> Colorex.analogous(Colorex.parse!("#3355FF"))
  {Colorex.parse!("#33BBFF"), Colorex.parse!("#7733FF")}

between(color1, color2, n \\ 1)

Returns n color(s) between the input colors

Returns a list of colors that bridge the gap between the two input colors.

N does not include the input colors, so if you want a total of 10 colors, you would call this function with n equal to 8.

## Examples:

  iex> Colorex.between(Colorex.parse!("#3355FF"), Colorex.parse!("#C27E70"), 4)
  [Colorex.parse!("#3FE1F3"),
   Colorex.parse!("#4BE785"),
   Colorex.parse!("#87DA58"),
   Colorex.parse!("#CEC464")]

complement(color)

@spec complement(color :: Colorex.Colorex.color()) :: Colorex.Colorex.color()

Returns the complement of a color in HSL colorspace.

## Examples:

  iex> Colorex.complement(Colorex.parse!("#3355FF"))
  Colorex.parse!("#FFDD33")

display_palettes(list, size \\ 2)

Displays a list of color palettes

The default inspecting of the color palettes from get_palettes/2 isn't the easiest to see the colors.

Pass in the results from get_palettes/2 and see each color palette printing in a row.

The optional second argument is the size of each color square.

Requires a terminal that supports truecolor/24-bit color.

get_palettes(n, seed \\ "")

@spec get_palettes(n :: pos_integer(), seed :: String.t()) :: [[Colorex.Color.t()]]

Generates N color palettes.

Pass in how many color palettes you want to see.

The optional second argument(pass in any string) is used to generate an offset so you can get some new color palettes.

Pass the result into display_palettes/2 for a better viewing of the color palettes

Examples:

iex> Colorex.Palette.get_palettes(2, "random string")
[
  [Colorex.parse!("#CADDEC"), Colorex.parse!("#5F8CC0"), Colorex.parse!("#143D86"), Colorex.parse!("#F2F2DF")],
  [Colorex.parse!("#8978AF"), Colorex.parse!("#FCA0A2"), Colorex.parse!("#FCC4C6"), Colorex.parse!("#367E72")]
]

tetradic(color)

@spec tetradic(color :: Colorex.Colorex.color()) ::
  {Colorex.color(), Colorex.color(), Colorex.color()}

Returns tetradic colors for the input color

returns a tuple of three colors that are 90°, 180°, and 270° away from the input color.

## Examples:

  iex> Colorex.tetradic(Colorex.parse!("#3355FF"))
  {Colorex.parse!("#FF33BB"), Colorex.parse!("#FFDD33"), Colorex.parse!("#33FF77")}

triadic(color, degrees \\ 120)

@spec triadic(color :: Colorex.Colorex.color(), degrees :: pos_integer()) ::
  {Colorex.color(), Colorex.color()}

Returns triadic colors for the input color

returns a tuple of two colors that are N degrees(default 120°) away

## Examples:

  iex> Colorex.triadic(Colorex.parse!("#3355FF"))
  {Colorex.parse!("#55FF33"), Colorex.parse!("#FF3355")}