Main Page   Modules   File List   Globals  

graphics.c File Reference

Character drawing. More...


Functions

void caca_set_color (enum caca_color fgcolor, enum caca_color bgcolor)
 Set the default colour pair.

enum caca_color caca_get_fg_color (void)
 Get the current foreground colour.

enum caca_color caca_get_bg_color (void)
 Get the current background colour.

void caca_putchar (int x, int y, char c)
 Print a character.

void caca_putstr (int x, int y, char const *s)
 Print a string.

void caca_printf (int x, int y, char const *format,...)
 Format a string.

void caca_clear (void)
 Clear the screen.

int caca_set_window_title (char const *title)
 Set the window title.

unsigned int caca_get_window_width (void)
 Get the window width.

unsigned int caca_get_window_height (void)
 Get the window height.

void caca_set_delay (unsigned int usec)
 Set the refresh delay.

unsigned int caca_get_rendertime (void)
 Get the average rendering time.

void caca_refresh (void)
 Flush pending changes and redraw the screen.


Detailed Description

Version:
$Id: graphics.c 258 2004-01-26 10:52:30Z sam $
Author:
Sam Hocevar <sam@zoy.org> This file contains character and string drawing functions.

Function Documentation

void caca_clear void   
 

This function clears the screen using a black background.

enum caca_color caca_get_bg_color void   
 

This function returns the current background colour that was set with caca_set_color().

Returns:
The current background colour.

enum caca_color caca_get_fg_color void   
 

This function returns the current foreground colour that was set with caca_set_color().

Returns:
The current foreground colour.

unsigned int caca_get_rendertime void   
 

This function returns the average rendering time, which is the average measured time between two caca_refresh() calls, in microseconds. If constant framerate was activated by calling caca_set_delay(), the average rendering time will not be considerably shorter than the requested delay even if the real rendering time was shorter.

Returns:
The render time in microseconds.

unsigned int caca_get_window_height void   
 

If libcaca runs in a window, get the usable window height. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, assume a 6x10 font is being used. Note that the units are not necessarily pixels.

Returns:
The window height.

unsigned int caca_get_window_width void   
 

If libcaca runs in a window, get the usable window width. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, assume a 6x10 font is being used. Note that the units are not necessarily pixels.

Returns:
The window width.

void caca_printf 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 screen 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:
x  X coordinate.
y  Y coordinate.
format  The format string to print.
...  Arguments to the format string.

void caca_putchar int    x,
int    y,
char    c
 

This function prints a character at the given coordinates, using the default foreground and background values. If the coordinates are outside the screen boundaries, nothing is printed.

Parameters:
x  X coordinate.
y  Y coordinate.
c  The character to print.

void caca_putstr int    x,
int    y,
char const *    s
 

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

Parameters:
x  X coordinate.
y  Y coordinate.
s  The string to print.

void caca_refresh void   
 

This function flushes all graphical operations and prints them to the screen. Nothing will show on the screen until caca_refresh() is called.

If caca_set_delay() was called with a non-zero value, caca_refresh() will use that value to achieve constant framerate: if two consecutive calls to caca_refresh() are within a time range shorter than the value set with caca_set_delay(), the second call will wait a bit before performing the screen refresh.

void caca_set_color enum caca_color    fgcolor,
enum caca_color    bgcolor
 

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 colour pairs.

Parameters:
fgcolor  The requested foreground colour.
bgcolor  The requested background colour.

void caca_set_delay unsigned int    usec
 

This function sets the refresh delay in microseconds. The refresh delay is used by caca_refresh() to achieve constant framerate. See the caca_refresh() documentation for more details.

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

Parameters:
usec  The refresh delay in microseconds.

int caca_set_window_title char const *    title
 

If libcaca runs in a window, try to change its title. This works with the X11 and Win32 drivers.

Parameters:
title  The desired window title.
Returns:
0 upon success, a non-zero value if an error occurs.