Code Monkey home page Code Monkey logo

clj-figlet's Introduction

clj-figlet

A Clojure library to generate text banners in an 'ASCII Art' style using FIGlet fonts, similar to other FIGlet programs.

Usage

"clj-figlet version"

You'll need to download one or more FIGlet fonts first. Probably the best place to get these is the FIGlet font database. Once you've got some ready loading them up is easy:

(use 'clj-figlet.core)

(def flf (load-flf "/Users/gered/roman.flf"))

load-flf returns a map which you will need to pass as the flf argument to any of the render functions. Some useful properties of flf fonts are present in the :header key.

Rendering characters, strings, multi-line strings are all easy. For example:

(render-char flf \A)

render-char, render-line and render all return the rendered output as sequences of strings. Each string in the sequence corresponds to a line of rendered output (a line of 'pixels' if you like). The number of strings will be equal to the height of the font (which is stored in the flf header under :height).

If we just cared about getting some nice output right away (e.g. for use when outputting to the console):

(println
  (clojure.string/join
    \newline
    (render-char flf \A)))
     _
    / \
   / _ \
  / ___ \
 /_/   \_\

=> nil

Rendering whole strings is just as easy:

(println
  (clojure.string/join
    \newline
    (render flf "Hello, world!")))
  _   _          _   _                                           _       _   _
 | | | |   ___  | | | |   ___         __      __   ___    _ __  | |   __| | | |
 | |_| |  / _ \ | | | |  / _ \        \ \ /\ / /  / _ \  | '__| | |  / _` | | |
 |  _  | |  __/ | | | | | (_) |  _     \ V  V /  | (_) | | |    | | | (_| | |_|
 |_| |_|  \___| |_| |_|  \___/  ( )     \_/\_/    \___/  |_|    |_|  \__,_| (_)
                                |/
=> nil

For convenience sake, you can also use the render-to-string function:

(println (render-to-string flf "w00t!"))
              ___     ___    _     _
 __      __  / _ \   / _ \  | |_  | |
 \ \ /\ / / | | | | | | | | | __| | |
  \ V  V /  | |_| | | |_| | | |_  |_|
   \_/\_/    \___/   \___/   \__| (_)

=> nil

Please note that currently, clj-figlet only supports the 'Full Size' layout mode as detailed in the FIGfont specifications. The 'Fitting Only' and 'Smushing' layout modes will be added in the future.

License

Distributed under the the MIT License. See LICENSE for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.