libcucul canvas drawing


Functions

void cucul_set_color (cucul_canvas_t *, unsigned char, unsigned char)
 Set the default colour pair.
void cucul_set_truecolor (cucul_canvas_t *, unsigned int, unsigned int)
 Set the default colour pair (truecolor version).
char const * cucul_get_color_name (unsigned int)
 Translate a colour index into the colour's name.
void cucul_putchar (cucul_canvas_t *, int, int, char)
 Print an ASCII character.
void cucul_putstr (cucul_canvas_t *, int, int, char const *)
 Print a string.
void cucul_printf (cucul_canvas_t *, int, int, char const *,...)
 Print a formated string.
void cucul_clear_canvas (cucul_canvas_t *, unsigned char)
 Clear the canvas.
void cucul_blit (cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *)
 Blit a canvas onto another one.

Detailed Description

These functions provide low-level character printing routines and higher level graphics functions.

Function Documentation

void cucul_set_color cucul_canvas_t cv,
unsigned char  fg,
unsigned char  bg
 

This function sets the default ANSI colour pair. String functions such as caca_printf() and graphical primitive functions such as caca_draw_line() will use these colours.

Color values are those defined in cucul.h, such as CUCUL_COLOR_RED or CUCUL_COLOR_TRANSPARENT.

Parameters:
cv A handle to the libcucul canvas.
fg The requested foreground colour.
bg The requested background colour.

void cucul_set_truecolor cucul_canvas_t cv,
unsigned int  fg,
unsigned int  bg
 

This function sets the default colour pair. String functions such as caca_printf() and graphical primitive functions such as caca_draw_line() will use these colours.

Colors are 16-bit ARGB values, each component being coded on 4 bits. For instance, 0xf088 is solid dark cyan (A=15 R=0 G=8 B=8), and 0x8fff is white with 50% alpha (A=8 R=15 G=15 B=15).

Parameters:
cv A handle to the libcucul canvas.
fg The requested foreground colour.
bg The requested background colour.

char const* cucul_get_color_name unsigned int  color  ) 
 

This function translates a cucul_color enum into a human-readable description string of the associated colour.

Parameters:
color The colour value.
Returns:
A static string containing the colour's name.

void cucul_putchar cucul_canvas_t cv,
int  x,
int  y,
char  ch
 

This function prints an ASCII character at the given coordinates, using the default foreground and background values. If the coordinates are outside the canvas boundaries, nothing is printed. If the character value is a non-printable character or is outside the ASCII range, it is replaced with a space. To print a sequence of bytes forming an UTF-8 character, use cucul_putstr() instead.

Parameters:
cv A handle to the libcucul canvas.
x X coordinate.
y Y coordinate.
ch The character to print.

void cucul_putstr cucul_canvas_t cv,
int  x,
int  y,
char const *  s
 

This function prints an UTF-8 string at the given coordinates, using the default foreground and background values. The coordinates may be outside the canvas boundaries (eg. a negative Y coordinate) and the string will be cropped accordingly if it is too long.

Parameters:
cv A handle to the libcucul canvas.
x X coordinate.
y Y coordinate.
s The string to print.

void cucul_printf cucul_canvas_t cv,
int  x,
int  y,
char const *  format,
  ...
 

This function formats a string at the given coordinates, using the default foreground and background values. The coordinates may be outside the canvas boundaries (eg. a negative Y coordinate) and the string will be cropped accordingly if it is too long. The syntax of the format string is the same as for the C printf() function.

Parameters:
cv A handle to the libcucul canvas.
x X coordinate.
y Y coordinate.
format The format string to print.
... Arguments to the format string.

void cucul_clear_canvas cucul_canvas_t cv,
unsigned char  bg
 

This function clears the canvas using the given background colour.

Parameters:
cv The canvas to clear.
bg The background colour to use.

void cucul_blit cucul_canvas_t dst,
int  x,
int  y,
cucul_canvas_t const *  src,
cucul_canvas_t const *  mask
 

This function blits a canvas onto another one at the given coordinates. An optional mask canvas can be used.

Parameters:
dst The destination canvas.
x X coordinate.
y Y coordinate.
src The source canvas.
mask The mask canvas.