Ascii art in the console

Sometimes I log a number to the console with a simple println() and it may get lost among other texts. So today I did this:

fun asciiText(text: String, font: String = "doh") =
    Runtime.getRuntime().exec("pyfiglet -f $font $text").inputStream.bufferedReader().readText().trimEnd()

This only works if you have pyfiglet installed.

Then I use it like this:

println(asciiText(circles.size.toString()))
println(asciiText("circles.size", "cybermedium"))

and the output:

> Task :p2026_08.LaserHoles01Kt.main()
kotlin-logging: initializing... active logger factory: Slf4jLoggerFactory
                                                          
                                                          
     999999999      222222222222222         888888888     
   99:::::::::99   2:::::::::::::::22     88:::::::::88   
 99:::::::::::::99 2::::::222222:::::2  88:::::::::::::88 
9::::::99999::::::92222222     2:::::2 8::::::88888::::::8
9:::::9     9:::::9            2:::::2 8:::::8     8:::::8
9:::::9     9:::::9            2:::::2 8:::::8     8:::::8
 9:::::99999::::::9         2222::::2   8:::::88888:::::8 
  99::::::::::::::9    22222::::::22     8:::::::::::::8  
    99999::::::::9   22::::::::222      8:::::88888:::::8 
         9::::::9   2:::::22222        8:::::8     8:::::8
        9::::::9   2:::::2             8:::::8     8:::::8
       9::::::9    2:::::2             8:::::8     8:::::8
      9::::::9     2:::::2       2222228::::::88888::::::8
     9::::::9      2::::::2222222:::::2 88:::::::::::::88 
    9::::::9       2::::::::::::::::::2   88:::::::::88   
   99999999        22222222222222222222     888888888
____ _ ____ ____ _    ____ ____  ____ _ ___  ____ 
|    | |__/ |    |    |___ [__   [__  |   /  |___ 
|___ | |  \ |___ |___ |___ ___] .___] |  /__ |___
[main] INFO org.openrndr.internal.gl3.ApplicationGLFWGL3 - 3.5.0 Wayland X11 GLX Null EGL OSMesa monotonic shared
[main] INFO org.openrndr.internal.gl3.ApplicationGLFWGL3 - OpenGL vendor: NVIDIA Corporation
[main] INFO org.openrndr.internal.gl3.ApplicationGLFWGL3 - OpenGL renderer: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2
[main] INFO org.openrndr.internal.gl3.ApplicationGLFWGL3 - OpenGL version: 4.6.0 NVIDIA 580.178.04
[main] WARN org.openrndr.internal.gl3.ShaderUniformsGL3 - Shader 'shade-style-custom:expansion-1590419418' does not have a uniform called 'bounds'

Hard to miss it now :sweat_smile:

ps. fonts here

1 Like