struct

Term2::Color

Inherits Struct < Value < Object

Color represents terminal colors (ANSI, 256-color, or TrueColor)

Constants

ANSI16_PALETTE = [{0, 0, 0}, {205, 0, 0}, {0, 205, 0}, {205, 205, 0}, {0, 0, 238}, {205, 0, 205}, {0, 205, 205}, {229, 229, 229}, {127, 127, 127}, {255, 0, 0}, {0, 255, 0}, {255, 255, 0}, {92, 92, 255}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255}]
BLACK = new(Type::Named, 0)

Named colors (ANSI 16)

BLUE = new(Type::Named, 4)
BRIGHT_BLACK = new(Type::Named, 8)

Bright named colors

BRIGHT_BLUE = new(Type::Named, 12)
BRIGHT_CYAN = new(Type::Named, 14)
BRIGHT_GREEN = new(Type::Named, 10)
BRIGHT_MAGENTA = new(Type::Named, 13)
BRIGHT_RED = new(Type::Named, 9)
BRIGHT_WHITE = new(Type::Named, 15)
BRIGHT_YELLOW = new(Type::Named, 11)
CYAN = new(Type::Named, 6)
GREEN = new(Type::Named, 2)
MAGENTA = new(Type::Named, 5)
RED = new(Type::Named, 1)
WHITE = new(Type::Named, 7)
YELLOW = new(Type::Named, 3)

Constructors

from_hex(hex : String) : Color

Create from hex string like "#FF5500", "FF5500", "#F50", or "F50"

Source
hex(hex : String) : Color

Compatibility alias used by some example ports.

Source
indexed(index : Int32) : Color

Create an indexed color (0-255)

Source
new(type : Type, value : Int32 | Tuple(Int32, Int32, Int32))
Source
rgb(r : Int32, g : Int32, b : Int32) : Color

Create an RGB color

Source

Class methods

ansi256_index_to_rgb(index : Int32) : Tuple(Int32, Int32, Int32)
Source
rgb_to_ansi16_index(r : Int32, g : Int32, b : Int32) : Int32
Source
rgb_to_ansi256_index(r : Int32, g : Int32, b : Int32) : Int32
Source

Instance methods

==(other : Color) : Bool

For equality comparison

Source
background_codes

Get background escape codes

Source
foreground_codes

Get foreground escape codes

Source
to_rgb
Source
type
Source
value
Source

Nested types