module

AsciiArt

AsciiArt — pure-Crystal ASCII art generation.

v0.1 ships a FIGlet-style text-to-banner renderer with five embedded fonts (no external runtime dependency).

require "asciiart"

# One-liner: render text with the default `standard` font.
puts AsciiArt.render("Hello")

# Choose a built-in font.
puts AsciiArt.render("Hello", font: "slant")

# Discover what's available.
AsciiArt.fonts # => ["banner", "big", "slant", "small", "standard"]

# Load your own font from disk.
font = AsciiArt::Fonts.load_file("./mycustom.flf")
puts AsciiArt::Renderer.new(font).render("Hi")

Constants

DEFAULT_FONT = "standard"

Default font used by render when no font argument is given.

VERSION = {{ (((read_file("/tmp/tmp.elnOOJ/src/src/ascii_art/../../shard.yml")) .lines .find(&.starts_with?("version:")) || "version: 0.0.0") .gsub(/^version:\s*/, "")) .chomp }}

Lue au compile-time depuis shard.yml via le macro read_file. Cf. note mémoire feedback_shard_version_macro.md (mémoire ALOLI).

Class methods

fonts

Lists the names of every built-in font.

Source
render(text : String, font : String = DEFAULT_FONT) : String

Renders text as ASCII art using the named built-in font. Returns the multi-line banner as a single string with \n between rows. Convenience wrapper around Renderer#render.

Source
render_lines(text : String, font : String = DEFAULT_FONT) : Array(String)

Same as render but returns one entry per row of the banner. Useful when the caller wants to colourise each row, frame the output, or measure the bounding box.

Source

Nested types