Term-Graille

Graphical Display in the terminal using UTF8 Braille characters


License
Artistic-1.0

Documentation

Term-Graille

Braille Characters for Terminal Graphical Applications

termgraille

Drawille is a method of using Braille characters as a mechanism for graphical display in a terminal. Ports of the original by asciimoo exist inmultiple other languages including Perl, Java, Rust, NodeJS, and others. The Perl version was initially produced by @hoelzro, but not much changed since about 8 years ago.

This is another Perl version, targeting ANSI compatible consoles. It delivers significantly higher performance and extends Term::Drawille by including features like:-

  • Integrated Turtle-like drawing
  • Built-in drawing primitives including line and curve, circle, ellipse, polyline more on the way
  • Scrolling with or without wrapping
  • Some frame border manipulation
  • Text overlays

Tools in other languages have been used in publications, system monitoring tools and for games. Term::Graille allows Perl programmers access to a expanding set of features for developing simple general purpose graphics, graphing applications, games etc from the console.

Assocoiated with Term::Graille is Algorithm::Line::Bresenham. The plotting primitives in the latter are used in Graille

Features to be included are colors, sprites, maps, and more on user request.

Version 0.06

Importing images

Graille does not have the resolution for fancy graphics. Having said that, images converted into mono with appropriate dithering can be surpisingly recognisable at the low resolution oferred. The image2grl.pl script in the examples folder uses Image Magick to perform the transromation down to a Graille canvas's resolutions, and plotted on to the canvas pixel by pixel. Graille offers the option to import or export .grl files.

grailleimage

Animation Demo

The animation demo uses Image::Magick to convert a folder of frames into monochrome images, which are then converted to bitmap plots on a canvas. These bitmap plots are displayed sequentially creating an animation.

This is an animation derived from a sprite sheet at Adobe stock photos which do a 30 day free trial.

animate

Fonts

In the initial demo above a Turtle script was used to produce a drawing of text. This is rather combersome. Fortunately bitmap fonts exist, and can be easily converted to Braille. DamienG has produced a series of 8X8 fonts which can translated into 4X2 braille characters. The fonts are consistently coded, so font2grf.pl in the example folders converts the Z80 assembly data into .grf files for importing into Graille. Fonts are not the only thing that can be transformed, and one imagines potential for sprites or tilemaps to be similarly encoded.

fonts

Variable thickness Lines

Herbert Breuning had made this suggestion. There are many examples of thick line algorithms on the net. Alan Murphy gives the classic version, which has been improved and it is this code that has been ported to Perl and used in Algorth::Line::Bresenham v0.151. INtegrating these into Graille was in v0.08.

Screenshot from 2022-08-02 18-32-01

Drop down menu

In developing a sprite editor on the console, mulitiple user interactions were required. Interactive graphical menus are not easy in the console. Tickit and Term::Menus are powerful modules. Term::Graille::Menu goes for simplicity rather than power. This comes in v 0.09. The sprite editor itself is not complete yet, but would be very cumbersome without something to aid visual development with multiple options and features.Term::Graille::Menu makes it very simple to create menus for ANSI terminals.

The menu in this image is created using:

my $menu=new Term::Graille::Menu(
          menu=>[["File","New Sprite Bank","Save Sprite Bank","Load Sprite Bank","Quit"],
                 ["Sprites","New Sprite","Delete Sprite","Import Sprite","Export Sprite"],
                 ["Edit","Clear","MirrorX","MirrorY","Rotate+","Rotate-",
                                             ["Reformat","2x4","4x4"],
                                             ["Scroll","left","right","up","down"]],
                 "About"],
          redraw=>\&main::refreshScreen,
          callback=>\&main::menuActions,
          );
          

menu

Audio

A component of interaction often negl;ected in terminal aplications is sound. Sound also adds an extra dimension to ganes. Term::Graille::Audio attempts to add sound with the least possible dependencies. It curently depends on pulseaudio in Linux (and Win32::Sound on windows although this is as yet untested). At its simplest Audio can play a sound from its built-in sound sample set which it autgenerates.

use Term::Graille::Audio;

my $beep=Term::Graille::Audio->new();    # TERM::Graille's Audio module
$beep->playSound(undef, "A#1");
piano.webm