Package com.tonic.vellum.style
Class Color
- java.lang.Object
-
- com.tonic.vellum.style.Color
-
public final class Color extends java.lang.ObjectAn immutable terminal color: the terminal default, a named ANSI color, a 256-color palette index, or 24-bit RGB. Instances compare by value.
-
-
Field Summary
Fields Modifier and Type Field Description static ColorBLACKstatic ColorBLUEstatic ColorBRIGHT_BLACKstatic ColorBRIGHT_BLUEstatic ColorBRIGHT_CYANstatic ColorBRIGHT_GREENstatic ColorBRIGHT_MAGENTAstatic ColorBRIGHT_REDstatic ColorBRIGHT_WHITEstatic ColorBRIGHT_YELLOWstatic ColorCYANstatic ColorDEFAULTThe terminal's default color.static ColorGREENstatic ColorMAGENTAstatic ColorREDstatic ColorWHITEstatic ColorYELLOW
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Coloransi256(int index)Creates a color from a 256-color palette index.java.lang.StringbackgroundSgr()booleanequals(java.lang.Object o)java.lang.StringforegroundSgr()inthashCode()static Colorrgb(int red, int green, int blue)Creates a 24-bit truecolor.java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT
public static final Color DEFAULT
The terminal's default color.
-
BLACK
public static final Color BLACK
-
RED
public static final Color RED
-
GREEN
public static final Color GREEN
-
YELLOW
public static final Color YELLOW
-
BLUE
public static final Color BLUE
-
MAGENTA
public static final Color MAGENTA
-
CYAN
public static final Color CYAN
-
WHITE
public static final Color WHITE
-
BRIGHT_BLACK
public static final Color BRIGHT_BLACK
-
BRIGHT_RED
public static final Color BRIGHT_RED
-
BRIGHT_GREEN
public static final Color BRIGHT_GREEN
-
BRIGHT_YELLOW
public static final Color BRIGHT_YELLOW
-
BRIGHT_BLUE
public static final Color BRIGHT_BLUE
-
BRIGHT_MAGENTA
public static final Color BRIGHT_MAGENTA
-
BRIGHT_CYAN
public static final Color BRIGHT_CYAN
-
BRIGHT_WHITE
public static final Color BRIGHT_WHITE
-
-
Method Detail
-
ansi256
public static Color ansi256(int index)
Creates a color from a 256-color palette index.- Parameters:
index- palette index, clamped to 0-255- Returns:
- the indexed color
-
rgb
public static Color rgb(int red, int green, int blue)
Creates a 24-bit truecolor.- Parameters:
red- red channel, clamped to 0-255green- green channel, clamped to 0-255blue- blue channel, clamped to 0-255- Returns:
- the RGB color
-
foregroundSgr
public java.lang.String foregroundSgr()
- Returns:
- the SGR parameters for this color as the foreground, without the leading separator
-
backgroundSgr
public java.lang.String backgroundSgr()
- Returns:
- the SGR parameters for this color as the background, without the leading separator
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-