Raxol.Core.Renderer.Color (Raxol v0.4.0)

View Source

Provides comprehensive color support for terminal rendering.

Supports:

  • ANSI 16 colors (4-bit)
  • ANSI 256 colors (8-bit)
  • True Color (24-bit)
  • Color themes
  • Terminal background detection

Summary

Functions

Creates a color theme map.

Returns the default color theme.

Detects the terminal's background color. Returns :light or :dark.

Converts a hex color string to RGB.

Converts RGB values to the nearest ANSI 256 color code.

Converts a color representation to its ANSI foreground escape code.

Converts a color representation to its ANSI background escape code.

Types

ansi_16()

@type ansi_16() ::
  :black
  | :red
  | :green
  | :yellow
  | :blue
  | :magenta
  | :cyan
  | :white
  | :bright_black
  | :bright_red
  | :bright_green
  | :bright_yellow
  | :bright_blue
  | :bright_magenta
  | :bright_cyan
  | :bright_white

ansi_256()

@type ansi_256() :: 0..255

color()

@type color() :: ansi_16() | ansi_256() | true_color()

true_color()

@type true_color() :: {0..255, 0..255, 0..255}

Functions

create_theme(colors)

Creates a color theme map.

default_theme()

Returns the default color theme.

detect_background()

Detects the terminal's background color. Returns :light or :dark.

hex_to_rgb(arg)

Converts a hex color string to RGB.

rgb_to_ansi256(arg)

Converts RGB values to the nearest ANSI 256 color code.

to_ansi(color)

Converts a color representation to its ANSI foreground escape code.

to_bg_ansi(color)

Converts a color representation to its ANSI background escape code.