Package com.marcpg.libpg.color
Class Ansi
java.lang.Object
com.marcpg.libpg.color.Ansi
Ansi formatting can be used in nearly any text-based console.
It is very commonly used and supports many different formatting options, from bold, to blinking, to colored text, just everything.
- Since:
- 0.0.1
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Ansi
Use the alternate fontstatic final Ansi
Blackstatic final Ansi
Makes the text blink, not widely supportedstatic final Ansi
Turns the blinking offstatic final Ansi
Bluestatic final Ansi
Makes the text bold/thickstatic final Ansi
Bright Bluestatic final Ansi
Bright Cyan/Aquastatic final Ansi
Brown / Orange / Ugly Yellowstatic final Ansi
Cyan / Aquastatic final Ansi
Dark Graystatic final Ansi
Dark Redstatic final Ansi
Resets the fontstatic final Ansi
Good Questionstatic final Ansi
Good Questionstatic final Ansi
Graystatic final Ansi
Dark Greenstatic final Ansi
Makes the text italic/cursivestatic final Ansi
Turns italic/cursive offstatic final Ansi
Lime / Bright Greenstatic final Ansi
Dark Magentastatic final Ansi
Overlines the text, not widely supportedstatic final Ansi
Pink / Bright Magentastatic final Ansi
Redstatic final Ansi
Resets all formattingstatic final Ansi
Resets the background colorstatic final Ansi
Resets the foreground colorstatic final Ansi
Makes the text strikethroughstatic final Ansi
Turns strikethrough offstatic final Ansi
Swaps the foreground and background colorsstatic final Ansi
Underlines the textstatic final Ansi
Turns underlined offstatic final Ansi
static final Ansi
Yellow -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
Makes the specified textblink
.static @NotNull String
Makes the specified textbold/thick
.static @NotNull String
formattedString
(String text, Ansi @NotNull ... formats) Apply a custom ansi format to a stringstatic @NotNull Ansi
Get a customAnsi
color based on a Java AWT color.static @NotNull Ansi
fromRGB
(int r, int g, int b) Get a customAnsi
color based on red, green and blue color values.get()
Gets the format as a string, so it's usable.Gets the color as a background color.static @NotNull String
Colors a specified textgray
, which can be used for secondary text for example.static @NotNull String
Colors a specified textgreen
, which can be used for infos or successes for example.static @NotNull String
Makes the specified textitalic
.static @NotNull String
Colors a specified textred
, which can be used for errors for example.toString()
Same asget()
static @NotNull String
Colors a specified textyellow
, which can be used for warnings for example.
-
Field Details
-
RESET
Resets all formatting -
RESET_FG
Resets the foreground color -
RESET_BG
Resets the background color -
BOLD
Makes the text bold/thick -
ITALIC
Makes the text italic/cursive -
UNDERLINE
Underlines the text -
BLINK
Makes the text blink, not widely supported -
SWAP_BG_FG
Swaps the foreground and background colors -
STRIKETHROUGH
Makes the text strikethrough -
DEFAULT_FONT
Resets the font -
ALT_FONT
Use the alternate font -
UNDERLINE_OFF
Turns underlined off -
BLINK_OFF
Turns the blinking off -
ITALIC_OFF
Turns italic/cursive off -
STRIKETHROUGH_OFF
Turns strikethrough off -
FRAMED
Good Question -
ENCIRCLED
Good Question -
OVERLINED
Overlines the text, not widely supported -
BLACK
Black -
DARK_RED
Dark Red -
GREEN
Dark Green -
BROWN
Brown / Orange / Ugly Yellow -
BLUE
Blue -
MAGENTA
Dark Magenta -
CYAN
Cyan / Aqua -
GRAY
Gray -
DARK_GRAY
Dark Gray -
RED
Red -
LIME
Lime / Bright Green -
YELLOW
Yellow -
BRIGHT_BLUE
Bright Blue -
PINK
Pink / Bright Magenta -
BRIGHT_CYAN
Bright Cyan/Aqua -
WHITE
-
-
Method Details
-
getBackground
Gets the color as a background color. This only works if it's really a color, otherwise it just returns the same asget()
- Returns:
- The color as a background color
- Since:
- 0.0.1
-
get
Gets the format as a string, so it's usable.- Returns:
- The ansi escape sequence
- Since:
- 0.0.1
-
toString
Same asget()
-
fromRGB
Get a customAnsi
color based on red, green and blue color values.- Parameters:
r
- Red (0-255)g
- Green (0-255)b
- Blue (0-255)- Returns:
- A custom ansi color
- Since:
- 0.0.1
-
fromColor
Get a customAnsi
color based on a Java AWT color.- Parameters:
color
- The Java AWT color- Returns:
- A custom ansi color
- Since:
- 0.0.1
-
formattedString
Apply a custom ansi format to a string- Parameters:
text
- The string that should be formattedformats
- What format should be applied- Returns:
- The formatted string
- Since:
- 0.0.1
-
gray
Colors a specified textgray
, which can be used for secondary text for example.
Uses dark gray, as some consoles makenormal gray
appear white.- Parameters:
text
- The text to color gray.- Returns:
- The colored text.
- See Also:
-
red
Colors a specified textred
, which can be used for errors for example.- Parameters:
text
- The text to color red.- Returns:
- The colored text.
- See Also:
-
yellow
Colors a specified textyellow
, which can be used for warnings for example.- Parameters:
text
- The text to color yellow.- Returns:
- The colored text.
- See Also:
-
green
Colors a specified textgreen
, which can be used for infos or successes for example.- Parameters:
text
- The text to color green.- Returns:
- The colored text.
- See Also:
-
blink
Makes the specified textblink
.- Parameters:
text
- The text to make blink.- Returns:
- The blinking text.
- See Also:
-
bold
Makes the specified textbold/thick
.- Parameters:
text
- The text to make bold/thick.- Returns:
- The bold/thick text.
- See Also:
-
italic
Makes the specified textitalic
.- Parameters:
text
- The text to make italic.- Returns:
- The italic text.
- See Also:
-