Skip to content

Instantly share code, notes, and snippets.

@timyates
Last active February 9, 2022 00:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timyates/f94453cd342212891e4d to your computer and use it in GitHub Desktop.
Save timyates/f94453cd342212891e4d to your computer and use it in GitHub Desktop.
Using AsciImage from Groovy
// Requires Groovy 2.4+ and Java 8
@Grab('com.bloidonia:ascii-image:1.1')
import com.bloidonia.asciiimage.AsciImageProcessor
import java.awt.image.BufferedImage
import java.awt.RenderingHints
import java.awt.Color
AsciImageProcessor.fromLines([
'. . . . . . .',
'. . 3 . . . .',
'. 1 2 . . . .',
'. . . . . 4 .',
'. 7 6 . . . .',
'. . 5 . . . .',
'. . . . . . .'
]).asBufferedImage { ctx ->
ctx.type(BufferedImage.TYPE_INT_ARGB)
.scale(5)
.graphics { g ->
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
g.paint = Color.BLACK
}
}.render()
@timyates
Copy link
Author

timyates commented Apr 8, 2015

@timyates
Copy link
Author

timyates commented Apr 8, 2015

Outputs the following (in the Groovy console):

arrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment