Raxol.Style.Colors.Harmony (Raxol v0.4.0)
View SourceProvides 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
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 baseColor{}
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.
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"
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)