Z
Z
Zadavatel_Voprosov2018-11-21 19:44:13
Java
Zadavatel_Voprosov, 2018-11-21 19:44:13

Hex colors in Java console output. Is it possible to?

Hello! I know that there are regular (ANSI) colors that are found in Google in 3 seconds, but I need other colors.

Like these ones
c6219df732d1.png
ANSI colors if needed
import java.io.*;

public class test {
  public static final String ANSI_RESET = "\u001B[0m";
  public static final String ANSI_BLACK = "\u001B[30m";
  public static final String ANSI_RED = "\u001B[31m";
  public static final String ANSI_GREEN = "\u001B[32m";
  public static final String ANSI_YELLOW = "\u001B[33m";
  public static final String ANSI_BLUE = "\u001B[34m";
  public static final String ANSI_PURPLE = "\u001B[35m";
  public static final String ANSI_CYAN = "\u001B[36m";
  public static final String ANSI_WHITE = "\u001B[37m";

  public static final String ANSI_BLACK_BACKGROUND = "\u001B[40m";
  public static final String ANSI_RED_BACKGROUND = "\u001B[41m";
  public static final String ANSI_GREEN_BACKGROUND = "\u001B[42m";
  public static final String ANSI_YELLOW_BACKGROUND = "\u001B[43m";
  public static final String ANSI_BLUE_BACKGROUND = "\u001B[44m";
  public static final String ANSI_PURPLE_BACKGROUND = "\u001B[45m";
  public static final String ANSI_CYAN_BACKGROUND = "\u001B[46m";
  public static final String ANSI_WHITE_BACKGROUND = "\u001B[47m";

  public static void main(String args[]) {

    System.out.print(ANSI_BLACK_BACKGROUND + ANSI_WHITE + "Белый текст на чёрном фоне." + ANSI_RESET);
  }
}

Can I get such colors in console output?
Also I would like...
Вот такую возможность форматирования консольного вывода
456489f31f1d.png

At least with Bold , Italic and Underlined text, the problem was solved like this:
public static final String ANSI_WHITE = "\u001B[37m";
public static final String ANSI_WHITE_BOLD = "\u001B[37;1m";
public static final String ANSI_WHITE_WAT = "\u001B[37;2m";
public static final String ANSI_WHITE_ITALIC = "\u001B[37;3m";
public static final String ANSI_WHITE_UNDERLINED = "\u001B[37;4m";

But what happens in ANSI_WHITE_WAT? It's some other color already.
321414c5b8ec.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question