CLASS METHODS

driver_list

Returns an hash which keys are the available display drivers and the values their descriptions.

drivers

Returns the list of available drivers.

METHODS

Constructor

new

Instantiates a Term::Caca object.

The optional argument driver can be passed to select a specific display driver. If it's not given, the best available driver will be used.

Display and Canvas

set_title( $title )

Sets the window title to $title.

Returns the invocant Term::Caca object.

refresh

Refreshes the display.

Returns the invocant Term::Caca object.

set_refresh_delay( $seconds )

Sets the refresh delay in seconds. The refresh delay is used by refresh to achieve constant framerate.

If the time is zero, constant framerate is disabled. This is the default behaviour.

Returns the invocant Term::Caca object.

rendering_time()

Returns the average rendering time, which is measured as the time between two refresh() calls, in seconds. If constant framerate is enabled via set_refresh_delay(), the average rendering time will be close to the requested delay even if the real rendering time was shorter.

clear()

Clears the canvas using the current background color.

Returns the invocant object.

canvas_size

Returns the width and height of the canvas, as a list in an array context, as a array ref in a scalar context.

canvas_width

Returns the canvas width.

canvas_height

Returns the canvas height.

mouse_position

Returns the position of the mouse. In a list context, returns the x, y coordinates, in a scalar context returns them as an array ref.

This function is not reliable if the ncurses or S-Lang drivers are being used, because mouse position is only detected when the mouse is clicked. Other drivers such as X11 work well.

Import/Export

import( $drawing, :$format => 'auto' )

Imports the drawing. The supported formats are

"auto": try to guess the format.

"caca": native libcaca files.

"ansi": ANSI art (CP437 charset with ANSI colour codes).

"text": ASCII text file.

"utf8": UTF-8 text with ANSI color codes.

export( :$format = 'caca' )

Returns the canvas in the given format.

Supported formats are

"caca": native libcaca files.

"ansi": ANSI art (CP437 charset with ANSI colour codes).

"text": ASCII text file.

"html": an HTML page with CSS information.

"html3": an HTML table that should be compatible with most navigators, including textmode ones.

"irc": UTF-8 text with mIRC colour codes.

"ps": a PostScript document.

"svg": an SVG vector image.

"tga": a TGA image.

Colors

set_ansi_color( $foreground, $background )

Sets the foreground and background colors used by primitives, using colors as defined by %COLORS.

$t->set_ansi_color( $LIGHTRED, $WHITE );

Returns the invocant object.

set_color( $foreground, $background )

Sets the foreground and background colors used by primitives.

Each color is an array ref to a ARGB (transparency + RGB) set of values, all between 0 and 15. Alternatively, they can be given as a string of the direct hexadecimal value.

# red on white
$t->set_color( [ 15, 15, 0, 0 ], 'ffff' );

Returns the invocant object.

Text

text( \@coord, $text )

Prints $text at the given coordinates.

Returns the invocant Term::Caca object.

char( \@coord, $char )

Prints the character $char at the given coordinates. If $char is a string of more than one character, only the first character is printed.

Returns the invocant Term::Caca object.

Primitives Drawing

line( \@point_a, \@point_b, :$char = undef )

Draws a line from @point_a to @point_b using the character $char or, if undefined, ascii art.

Returns the invocant object.

polyline( \@points, :$char = undef , :$close = 0 )

Draws the polyline defined by @points, where each point is an array ref of the coordinates. E.g.

$t->polyline( [ [ 0,0 ], [ 10,15 ], [ 20, 15 ] ] );

The lines are drawn using $char or, if not specified, using ascii art.

If $close is true, the end point of the polyline will be connected to the first point.

Returns the invocant Term::Caca object.

circle( \@center, $radius, :$char = '*', :$fill = undef )

Draws a circle centered at @center with a radius of $radius using the character $char or, if not defined, ascii art. if $fill is set to true, the circle is filled with $char as well.

If $fill is defined but $char is not, $fill will be taken as the filling character. I.e.,