struct
Opal::Color
- Opal::Color
- Struct
- Value
- Object
Overview
Color model supporting 16 standard ANSI colors, 256 indexed palette, and 24-bit TrueColor RGB.
Defined in:
opal/style/color.crConstructors
- .ansi(code : Int32) : Color
-
.from(val : Color | Symbol | String) : Color
Resolves a symbol or string (e.g.
-
.hex(raw : String) : Color
Parses hex string like "#ff79c6", "61AFEF", or "#fff"
- .index(code : Int32) : Color
-
.lerp(c1 : Color, c2 : Color, t : Float64) : Color
Linearly interpolates between two colors by factor t (0.0 to 1.0)
- .new(type : Type, code : Int32 = 0, r : UInt8 = 0_u8, g : UInt8 = 0_u8, b : UInt8 = 0_u8)
- .none : Color
- .rgb(r : Int, g : Int, b : Int) : Color
Class Method Summary
-
.black
Named color helpers
- .blue
- .bright_black
- .bright_blue
- .bright_cyan
- .bright_green
- .bright_magenta
- .bright_red
- .bright_white
- .bright_yellow
- .cyan
- .green
- .magenta
-
.no_color? : Bool
Checks whether colors are suppressed via NO_COLOR standard
- .red
- .white
- .yellow
Instance Method Summary
- #b : UInt8
-
#bg_escape : String
Emits the ANSI escape code for background
- #code : Int32
-
#fg_escape : String
Emits the ANSI escape code for foreground
- #g : UInt8
- #r : UInt8
-
#to_rgb : Tuple(UInt8, UInt8, UInt8)
Converts color to RGB tuple (approximate for ANSI)
- #type : Type
Constructor Detail
Resolves a symbol or string (e.g. :red, "#ff0000", "blue") into a Color
Parses hex string like "#ff79c6", "61AFEF", or "#fff"
Linearly interpolates between two colors by factor t (0.0 to 1.0)