struct Opal::Color

Overview

Color model supporting 16 standard ANSI colors, 256 indexed palette, and 24-bit TrueColor RGB.

Defined in:

opal/style/color.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.ansi(code : Int32) : Color #

[View source]
def self.from(val : Color | Symbol | String) : Color #

Resolves a symbol or string (e.g. :red, "#ff0000", "blue") into a Color


[View source]
def self.hex(raw : String) : Color #

Parses hex string like "#ff79c6", "61AFEF", or "#fff"


[View source]
def self.index(code : Int32) : Color #

[View source]
def self.lerp(c1 : Color, c2 : Color, t : Float64) : Color #

Linearly interpolates between two colors by factor t (0.0 to 1.0)


[View source]
def self.new(type : Type, code : Int32 = 0, r : UInt8 = 0_u8, g : UInt8 = 0_u8, b : UInt8 = 0_u8) #

[View source]
def self.none : Color #

[View source]
def self.rgb(r : Int, g : Int, b : Int) : Color #

[View source]

Class Method Detail

def self.black #

Named color helpers


[View source]
def self.blue #

[View source]
def self.bright_black #

[View source]
def self.bright_blue #

[View source]
def self.bright_cyan #

[View source]
def self.bright_green #

[View source]
def self.bright_magenta #

[View source]
def self.bright_red #

[View source]
def self.bright_white #

[View source]
def self.bright_yellow #

[View source]
def self.cyan #

[View source]
def self.green #

[View source]
def self.magenta #

[View source]
def self.no_color? : Bool #

Checks whether colors are suppressed via NO_COLOR standard


[View source]
def self.red #

[View source]
def self.white #

[View source]
def self.yellow #

[View source]

Instance Method Detail

def b : UInt8 #

[View source]
def bg_escape : String #

Emits the ANSI escape code for background


[View source]
def code : Int32 #

[View source]
def fg_escape : String #

Emits the ANSI escape code for foreground


[View source]
def g : UInt8 #

[View source]
def r : UInt8 #

[View source]
def to_rgb : Tuple(UInt8, UInt8, UInt8) #

Converts color to RGB tuple (approximate for ANSI)


[View source]
def type : Type #

[View source]