Raxol.Style.Colors.Harmony (Raxol v0.4.0)

View Source

Provides functions for generating color harmonies based on a base color.

Summary

Functions

Generates analogous colors based on the HSL color wheel. Analogous colors are groups of colors that are adjacent to each other on the color wheel.

Generates complementary colors (opposite on the color wheel).

Generates triadic colors (three colors evenly spaced on the color wheel).

Functions

analogous_colors(color, count \\ 3, angle \\ 30)

Generates analogous colors based on the HSL color wheel. Analogous colors are groups of colors that are adjacent to each other on the color wheel.

Parameters

  • color: The base Color{} struct.
  • count: The number of analogous colors to generate (defaults to 3).
  • angle: The angle separation between analogous colors (defaults to 30 degrees).

Returns

A list of Color{} structs representing the analogous colors.

complementary_colors(color)

Generates complementary colors (opposite on the color wheel).

Returns a list containing the base color and its complement.

Parameters

  • color - The base color (Color struct or hex string)

Returns

  • A list of two Color structs: [base_color, complement]

Examples

iex> red = Raxol.Style.Colors.Color.from_hex("#FF0000")
iex> [red_struct, cyan_struct] = Raxol.Style.Colors.Harmony.complementary_colors(red)
iex> cyan_struct.hex
"#00FFFF"

triadic_colors(color)

Generates triadic colors (three colors evenly spaced on the color wheel).

Parameters

  • color - The base color (Color struct or hex string)

Returns

  • A list of three Color structs

Examples

iex> red = Raxol.Style.Colors.Color.from_hex("#FF0000")
iex> colors = Raxol.Style.Colors.Harmony.triadic_colors(red)
iex> length(colors)
3
# Colors will be red, green, blue (approximately)