Pote.Harmonies (Pote v1.0.0)

Copy Markdown View Source

Color harmony generation based on color theory principles.

All functions take an RGB tuple and return lists of RGB tuples. Operations are purely mathematical — no I/O, no state.

Supported Harmonies

  • Complementary: Color opposite on the wheel (180°)
  • Analogous: Adjacent colors (±30°)
  • Triad: Three colors equidistant at 120°
  • Square: Four colors at 90° intervals
  • Monochromatic: Lightness variations of the same hue
  • Split Complementary: Complement ± flanking colors
  • Compound: Complement plus analogous neighbors

Type aliases defined here reference the canonical types in Pote.

Usage

iex> Pote.Harmonies.complementary({255, 87, 51})
[{51, 219, 255}]

iex> Pote.Harmonies.triad({255, 87, 51})
[{51, 255, 87}, {87, 51, 255}]

Summary

Functions

Returns analogous colors (±30° adjacent on the wheel).

Returns the analogous colors with custom angle.

Returns the complementary color (opposite on the hue wheel, +180°).

Returns compound (double complementary) harmony colors.

Darkens a color by mixing it with black.

Lightens a color by mixing it with white.

Returns monochromatic variations (same hue, different lightness).

Returns split complementary colors.

Returns square harmony colors (four colors equally spaced at 90°).

Returns the triad colors (three colors equally spaced at 120°).

Types

rgb()

@type rgb() :: Pote.rgb()

Functions

analogous(rgb)

@spec analogous(rgb()) :: [rgb()]

Returns analogous colors (±30° adjacent on the wheel).

Returns 2 colors: one at -30° and one at +30°.

Examples

iex> analogous({255, 0, 0})
[{255, 128, 0}, {255, 0, 128}]

analogous(rgb, angle)

@spec analogous(rgb(), float()) :: [rgb()]

Returns the analogous colors with custom angle.

Parameters

  • rgb - RGB color tuple
  • angle - Angle in degrees (default: 30)

Returns

  • List of 2 RGB color tuples

complementary(rgb)

@spec complementary(rgb()) :: [rgb()]

Returns the complementary color (opposite on the hue wheel, +180°).

Examples

iex> complementary({255, 0, 0})
[{0, 255, 255}]

compound(rgb)

@spec compound(rgb()) :: [rgb()]

Returns compound (double complementary) harmony colors.

Combines complementary and analogous: produces 4 colors forming two complementary pairs offset by 30°.

Examples

iex> compound({255, 0, 0}) |> length()
4

darker(arg, amount \\ 0.2)

@spec darker(rgb(), float()) :: rgb()

Darkens a color by mixing it with black.

Parameters

  • rgb - Source color
  • amount - Amount to darken (0.0–1.0, default: 0.2)

Examples

iex> darker({200, 200, 200}, 0.5)
{100, 100, 100}

lighter(arg, amount \\ 0.2)

@spec lighter(rgb(), float()) :: rgb()

Lightens a color by mixing it with white.

Parameters

  • rgb - Source color
  • amount - Amount to lighten (0.0–1.0, default: 0.2)

Examples

iex> lighter({100, 100, 100}, 0.5)
{178, 178, 178}

monochromatic(rgb, steps \\ 5)

@spec monochromatic(rgb(), pos_integer()) :: [rgb()]

Returns monochromatic variations (same hue, different lightness).

Generates steps variations evenly distributed in lightness from 20% to 80%.

Parameters

  • rgb - Source color
  • steps - Number of variations to generate (default: 5)

Examples

iex> monochromatic({255, 0, 0}, 3) |> length()
3

split_complementary(rgb)

@spec split_complementary(rgb()) :: [rgb()]

Returns split complementary colors.

Takes the complement (180°) then flanks it with ±30°. Returns 2 colors: complement-30° and complement+30°.

Examples

iex> split_complementary({255, 0, 0}) |> length()
2

square(rgb)

@spec square(rgb()) :: [rgb()]

Returns square harmony colors (four colors equally spaced at 90°).

Returns 3 additional colors (the original is implied as the first).

Examples

iex> square({255, 0, 0}) |> length()
3

triad(rgb)

@spec triad(rgb()) :: [rgb()]

Returns the triad colors (three colors equally spaced at 120°).

Returns 2 additional colors (the original is implied as the third).

Examples

iex> triad({255, 0, 0}) |> length()
2