class Term::Color

Included Modules

Defined in:

color/color.cr
color/colors.cr
color/env.cr
color/version.cr

Constant Summary

ANSI_COLOR_REGEXP = /\x1b+(\[|\[\[)[0-9;:?]+m/m
VERSION = "0.4.1"

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(red, green, blue, alpha = 255) #

Creates a new Cor instance from #red, #green, #blue and #alpha values.


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

Creates a new Cor instance from a hex string.


[View source]

Class Method Detail

def self.color(color) #

Gets one of the many color values defined in COLORS as a Cor instance.


[View source]
def self.command?(cmd : String, args : Array(String) = [] of String) #

Check if a command exists and can run with given args


[View source]
def self.from_hsb(h, s, b) #

Create a new Cor instance from hue, saturation, and brightness.


[View source]
def self.from_hsl(h, s, l) #

Create a new Cor instance from hue, saturation, and lightness.


[View source]
def self.from_hsv(h, s, v) #

Create a new Cor instance from hue, saturation, and value.


[View source]
def self.strip(string) #

Strip ANSI color codes from a string.

Only ANSI color codes are removed, not movement codes or other escapes sequences are stripped.


[View source]
def self.truecolor_string(string : String, fore = nil, back = nil, bold = false, faint = false, italic = false, underline = false, blink = false, strike = false, overline = false) #

Converts string to an ANSI escape sequence for use with truecolor enabled terminals. fore and back can be either a Cor instance or a symbol representing a COLORS value.


[View source]
def self.tty? #

True if STDOUT is a TTY


[View source]
def self.windows? #

True if running on Windows


[View source]

Instance Method Detail

def *(other : Term::Color) #

[View source]
def +(other : Term::Color) #

[View source]
def -(other : Term::Color) #

[View source]
def /(other : Term::Color) #

[View source]
def <=>(other) #

Implements the comparison operator for Cor.


[View source]
def alpha : Int32 #

alpha (opacity) value for this color


[View source]
def alpha=(value) #

Set the alpha value for this color. Can be either a float between 0 and 1, or a integer value between 0 and 255.


[View source]
def blue : Int32 #

blue value for this color


[View source]
def blue=(value) #

Set the blue value for this color


[View source]
def green : Int32 #

green value for this color


[View source]
def green=(value) #

Set the green value for this color


[View source]
def hex_string(prefix = false, alpha = false, upcase = false) #

Outputs this Cor instance as a hex string.


[View source]
def inverse #

Returns a new Cor that's the inverse of self.


[View source]
def pretty_print(pp) #

Pretty print (it's a rainbow!)


[View source]
def red : Int32 #

red value for this color


[View source]
def red=(value) #

Set the red value for this color


[View source]
def rgb_string(alpha = false) #

Outputs this Cor instance as a css rgb(a) string.


[View source]
def to_a #

Convert the Cor to an array.


[View source]
def to_h #

Convert the Cor to a hash.


[View source]
def to_hsb #

The HSb (hue / saturation / brightness) of the color


[View source]
def to_hsl #

The HSV (hue / saturation / lightness) of the color


[View source]
def to_hsv #

The HSV (hue / saturation / value) of the color


[View source]
def to_s #

Convert to a string


[View source]
def to_tuple #

Convert the Cor to a tuple.


[View source]