Alaja.Components.ColorWheel (Alaja v1.0.0)

Copy Markdown View Source

Color visualization component for the terminal.

Provides multiple rendering modes:

  • Native image (Kitty/iTerm2/Sixel): generates a real bitmap of the color wheel using the detected terminal protocol.
  • ASCII half-block (universal fallback): renders a circle using Unicode / characters with true-color ANSI (24-bit), yielding 2 pixels per vertical cell.

Detection is automatic — native rendering is attempted first and the component falls back to ASCII when the terminal does not support images.

Contracts

Este módulo usa los tipos definidos en Pote como fuente canónica.

Examples

alias Alaja.Components.ColorWheel

# Show color info
ColorWheel.show_color_info({255, 87, 51})

# Harmony ring
ColorWheel.show_harmony_ring({255, 0, 0}, :triad)

# Swatches
ColorWheel.show_swatches([{255, 0, 0}, {0, 255, 0}, {0, 0, 255}])

Summary

Functions

Computes the harmony colors for a given type and base RGB.

Extracts HSL hue angles from a list of RGB tuples.

Renders the ASCII color wheel and returns the lines (for layout composition).

Renders color format information as formatted terminal output.

Shows lighter/darker variants of a color.

Renders the color wheel as a PNG image and prints it to the terminal.

Renders a list of color swatches with hex labels.

Displays detailed color information: swatch, formats, and optional variants.

Shows a horizontal gradient between two colors.

Shows a harmony ring using ASCII rendering with autodetection of terminal capabilities. Falls back to ASCII half-block when the terminal does not support native image protocols.

Shows a list of colors as linear swatches.

Types

rgb()

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

Functions

compute_harmony(rgb, harmony_type)

@spec compute_harmony(rgb(), atom()) :: [rgb()]

Computes the harmony colors for a given type and base RGB.

extract_angles(rgbs)

@spec extract_angles([rgb()]) :: [number()]

Extracts HSL hue angles from a list of RGB tuples.

get_ascii_wheel_lines(harmony_angles, harmony_type, opts \\ [])

@spec get_ascii_wheel_lines([number()], atom(), keyword()) :: [String.t()]

Renders the ASCII color wheel and returns the lines (for layout composition).

harmony_display_name(arg1)

@spec harmony_display_name(atom()) :: String.t()

render_color_formats(rgb)

@spec render_color_formats(rgb()) :: :ok

Renders color format information as formatted terminal output.

render_color_variants(rgb)

@spec render_color_variants(rgb()) :: :ok

Shows lighter/darker variants of a color.

render_png_wheel(rgb_list, opts \\ [])

@spec render_png_wheel(
  [rgb()],
  keyword()
) :: iodata()

Renders the color wheel as a PNG image and prints it to the terminal.

This function generates a bitmap of the color wheel with harmony markers and outputs it using the detected image protocol (Kitty/iTerm2/Sixel).

Parameters

  • rgb_list - List of RGB tuples representing colors to mark on the wheel
  • opts - Options (same as get_ascii_wheel_lines)

render_swatch_list(colors)

@spec render_swatch_list([rgb()]) :: :ok

Renders a list of color swatches with hex labels.

show_color_info(color, opts \\ [])

@spec show_color_info(
  Pote.Orchestrator.color_input(),
  keyword()
) :: :ok

Displays detailed color information: swatch, formats, and optional variants.

show_gradient(start_color, end_color, steps \\ 20)

Shows a horizontal gradient between two colors.

show_harmony_ring(base_color, harmony_type \\ :triad, opts \\ [])

@spec show_harmony_ring(Pote.Orchestrator.color_input(), atom(), keyword()) :: :ok

Shows a harmony ring using ASCII rendering with autodetection of terminal capabilities. Falls back to ASCII half-block when the terminal does not support native image protocols.

show_swatches(colors, opts \\ [])

@spec show_swatches(
  [Pote.Orchestrator.color_input()],
  keyword()
) :: :ok

Shows a list of colors as linear swatches.