Search in sources :

Example 1 with AnsiColor

use of org.springframework.boot.ansi.AnsiColor in project spring-boot by spring-projects.

the class ImageBanner method printBanner.

private void printBanner(BufferedImage image, int margin, boolean invert, PrintStream out) {
    AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT);
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(background));
    out.println();
    out.println();
    AnsiColor lastColor = AnsiColor.DEFAULT;
    for (int y = 0; y < image.getHeight(); y++) {
        for (int i = 0; i < margin; i++) {
            out.print(" ");
        }
        for (int x = 0; x < image.getWidth(); x++) {
            Color color = new Color(image.getRGB(x, y), false);
            AnsiColor ansiColor = AnsiColors.getClosest(color);
            if (ansiColor != lastColor) {
                out.print(AnsiOutput.encode(ansiColor));
                lastColor = ansiColor;
            }
            out.print(getAsciiPixel(color, invert));
        }
        out.println();
    }
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(AnsiBackground.DEFAULT));
    out.println();
}
Also used : Color(java.awt.Color) AnsiColor(org.springframework.boot.ansi.AnsiColor) AnsiElement(org.springframework.boot.ansi.AnsiElement) AnsiColor(org.springframework.boot.ansi.AnsiColor)

Aggregations

Color (java.awt.Color)1 AnsiColor (org.springframework.boot.ansi.AnsiColor)1 AnsiElement (org.springframework.boot.ansi.AnsiElement)1