Top Description Fields Constructors Methods
io.github.darvil.terminal.textformatter.color

public Class TrueColor

extends Object
implements Color
Class Inheritance
All Implemented Interfaces
io.github.darvil.terminal.textformatter.color.Color
Imports
org.jetbrains.annotations.NotNull, io.github.darvil.terminal.textformatter.TextFormatter

Represents a true color in the RGB color space.

Note

Support for true color is not universal. Expect this implementation to work in most modern terminals, but not all.

Field Summary

Modifier and TypeField and Description
private final byte
b

public static final TrueColor
BLACK

The color black.

public static final TrueColor
BLUE

The color blue.

public static final TrueColor
CYAN

The color cyan.

private final byte
g

public static final TrueColor
GREEN

The color green.

public static final TrueColor
MAGENTA

The color magenta.

private final byte
r

public static final TrueColor
RED

The color red.

public static final TrueColor
WHITE

The color white.

public static final TrueColor
YELLOW

The color yellow.

Constructor Summary

AccessConstructor and Description
private
TrueColor(byte r, byte g, byte b)

Method Summary

Modifier and TypeMethod and Description
public byte

Returns:

The blue component of this color.
b
()

Returns the blue component of this color.

public @NotNull String
bg()

Implements io.github.darvil.terminal.textformatter.color.Color.bg.

Returns the ANSI escape sequence for this color for the text background.

public @NotNull String
fg()

Implements io.github.darvil.terminal.textformatter.color.Color.fg.

Returns the ANSI escape sequence for this color for the text foreground.

public byte

Returns:

The green component of this color.
g
()

Returns the green component of this color.

private @NotNull String
getSequence(boolean fg)

public static @NotNull TrueColor

Returns:

A new TrueColor object with the given RGB components.
of
(int
The red component, in the range 0-255.
r
,
int
The green component, in the range 0-255.
g
,
int
The blue component, in the range 0-255.
b
)

Creates a new TrueColor object with the given RGB components.

public static @NotNull TrueColor

Returns:

A new TrueColor object with the given RGB components.
of
(int
The RGB components packed into a single integer.
rgb
)

Creates a new TrueColor object with the given RGB components packed into a single integer.

public byte

Returns:

The red component of this color.
r
()

Returns the red component of this color.

public @NotNull String
toString()

Overrides java.lang.Object.toString.

Implements io.github.darvil.terminal.textformatter.color.Color.toString.

Returns the ANSI escape sequence for this color for the text foreground.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bback to summary
private final byte b
BLACKback to summary
public static final TrueColor BLACK

The color black.

BLUEback to summary
public static final TrueColor BLUE

The color blue.

CYANback to summary
public static final TrueColor CYAN

The color cyan.

gback to summary
private final byte g
GREENback to summary
public static final TrueColor GREEN

The color green.

MAGENTAback to summary
public static final TrueColor MAGENTA

The color magenta.

rback to summary
private final byte r
REDback to summary
public static final TrueColor RED

The color red.

WHITEback to summary
public static final TrueColor WHITE

The color white.

YELLOWback to summary
public static final TrueColor YELLOW

The color yellow.

Constructor Detail

TrueColorback to summary
private TrueColor(byte r, byte g, byte b)

Method Detail

bback to summary
public byte b()

Returns the blue component of this color.

Returns:byte

The blue component of this color.

bgback to summary
public @NotNull String bg()

Implements io.github.darvil.terminal.textformatter.color.Color.bg.

Doc from io.github.darvil.terminal.textformatter.color.Color.bg.

Returns the ANSI escape sequence for this color for the text background.

Annotations
@Override
@NotNull
fgback to summary
public @NotNull String fg()

Implements io.github.darvil.terminal.textformatter.color.Color.fg.

Doc from io.github.darvil.terminal.textformatter.color.Color.fg.

Returns the ANSI escape sequence for this color for the text foreground.

Annotations
@Override
@NotNull
gback to summary
public byte g()

Returns the green component of this color.

Returns:byte

The green component of this color.

getSequenceback to summary
private @NotNull String getSequence(boolean fg)
Annotations
@NotNull
ofback to summary
public static @NotNull TrueColor of(int r, int g, int b)

Creates a new TrueColor object with the given RGB components.

Parameters
r:int

The red component, in the range 0-255.

g:int

The green component, in the range 0-255.

b:int

The blue component, in the range 0-255.

Returns:@NotNull TrueColor

A new TrueColor object with the given RGB components.

Annotations
@NotNull
Exceptions
IllegalArgumentException:
If any of the color components are not in the range 0-255.
ofback to summary
public static @NotNull TrueColor of(int rgb)

Creates a new TrueColor object with the given RGB components packed into a single integer.

Parameters
rgb:int

The RGB components packed into a single integer.

Returns:@NotNull TrueColor

A new TrueColor object with the given RGB components.

Annotations
@NotNull
rback to summary
public byte r()

Returns the red component of this color.

Returns:byte

The red component of this color.

toStringback to summary
public @NotNull String toString()

Overrides java.lang.Object.toString.

Implements io.github.darvil.terminal.textformatter.color.Color.toString.

Doc from io.github.darvil.terminal.textformatter.color.Color.toString.

Returns the ANSI escape sequence for this color for the text foreground.

Annotations
@Override
@NotNull