caca_canvas(3caca)

πŸ’– NAME πŸ’–

caca_canvas β€” libcaca canvas drawing. Okay so this is the caca_canvas(3caca) page from libcaca, and it's literally the home of canvas drawing lore. ✨


✨ SYNOPSIS ✨

🧡 Topics

  • libcaca dirty rectangle manipulation β€” this is the topic linked up in here, bestie. That's the topic, and it's serving exactly what it says. πŸ’…

πŸͺ„ Macros

  • #define CACA_MAGIC_FULLWIDTH 0x000ffffe β€” the macro in question, with all its spaces and hex energy intact. πŸŽ€

🧚 Functions

  • __extern int caca_gotoxy (caca_canvas_t *, int, int) β€” sets the cursor position; it's giving "move the little cursor to a spot" energy.
  • __extern int caca_wherex (caca_canvas_t const *) β€” gets the X cursor position.
  • __extern int caca_wherey (caca_canvas_t const *) β€” gets the Y cursor position.
  • __extern int caca_put_char (caca_canvas_t *, int, int, uint32_t) β€” prints an ASCII or Unicode character.
  • __extern uint32_t caca_get_char (caca_canvas_t const *, int, int) β€” gets the Unicode character at the given coordinates.
  • __extern int caca_put_str (caca_canvas_t *, int, int, char const *) β€” prints a string.
  • __extern int caca_printf (caca_canvas_t *, int, int, char const *,...) β€” prints a formatted string.
  • __extern int caca_vprintf (caca_canvas_t *, int, int, char const *, va_list) β€” prints a formatted string, but the va_list version.
  • __extern int caca_clear_canvas (caca_canvas_t *) β€” clears the canvas.
  • __extern int caca_set_canvas_handle (caca_canvas_t *, int, int) β€” sets the cursor handle.
  • __extern int caca_get_canvas_handle_x (caca_canvas_t const *) β€” gets the X handle position.
  • __extern int caca_get_canvas_handle_y (caca_canvas_t const *) β€” gets the Y handle position.
  • __extern int caca_blit (caca_canvas_t *, int, int, caca_canvas_t const *, caca_canvas_t const *) β€” blits a canvas onto another one.
  • __extern int caca_set_canvas_boundaries (caca_canvas_t *, int, int, int, int) β€” sets a canvas' new boundaries.

πŸ’¬ Detailed Description πŸ’¬

These functions provide low-level character printing routines and higher level graphics functions. Lowkey iconic, highkey essential β€” it's the whole canvas crew in one place. 🫢


πŸ“š Macro Definition Documentation πŸ“š

πŸŽ€ #define CACA_MAGIC_FULLWIDTH 0x000ffffe πŸŽ€

Used to indicate that the previous character was a fullwidth glyph. πŸ¦‹

Referenced by caca_blit(), caca_flip(), caca_put_attr(), caca_put_char(), and caca_rotate_180(). πŸ‘‘

✨ Function Documentation ✨

Okay bestie, this is the actual function-by-function part, and honestly? It ate. Every one of these is a little icon. Let's go 🫢


πŸŽ€ caca_gotoxy

__extern int caca_gotoxy (caca_canvas_t * cv, int x, int y)

Puts the cursor exactly where you tell it to. Every function that cares about the cursor will pick up your shiny new values. And listen β€” setting the cursor outside the canvas is totally legal πŸ’…, it just means the cursor won't show up. It's giving "invited to the party but not on the guest list."

This function never fails. Never. Not once. Iconic.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X cursor coordinate.
  • y β€” Y cursor coordinate.

Returns This function always returns 0.

Referenced by caca_conio_cgets(), caca_conio_clrscr(), caca_conio_cprintf(), caca_conio_cputs(), caca_conio_gotoxy(), caca_conio_printf(), and caca_conio_putch().


πŸŽ€ caca_wherex

__extern int caca_wherex (caca_canvas_t const * cv)

Gives you the X coordinate of where the cursor is currently sitting. Like a location tag but for your cursor. πŸ“

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.

Returns The cursor's X coordinate.

Referenced by caca_conio_cgets(), caca_conio_clreol(), caca_conio_cprintf(), caca_conio_cputs(), caca_conio_printf(), caca_conio_putch(), and caca_conio_wherex().


πŸŽ€ caca_wherey

__extern int caca_wherey (caca_canvas_t const * cv)

Same energy as caca_wherex() but for the Y coordinate. Vertical bestie. πŸ¦‹

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.

Returns The cursor's Y coordinate.

Referenced by caca_conio_cgets(), caca_conio_clreol(), caca_conio_cprintf(), caca_conio_cputs(), caca_conio_printf(), caca_conio_putch(), and caca_conio_wherey().


πŸŽ€ caca_put_char

__extern int caca_put_char (caca_canvas_t * cv, int x, int y, uint32_t ch)

Prints an ASCII or Unicode character at the given coordinates, using the default foreground and background colour values. This is THE main character of the page honestly.

So here's the tea 🍡: if the coordinates are outside the canvas boundaries, nothing gets printed. Nada. If a fullwidth Unicode character gets overwritten, whatever parts of it are still visible get replaced with spaces. And if the canvas' boundaries would split the fullwidth character in two, a space is printed instead β€” because splitting a character is a crime and libcaca refuses to participate.

⚠️ Real talk: the behaviour when printing non-printable characters or invalid UTF-32 characters is undefined. That's not a vibe, that's a warning. Also β€” if you've got a sequence of bytes forming an UTF-8 character instead of an UTF-32 character, go use caca_put_str() instead, bestie.

This function returns the width of the printed character. Fullwidth character? You get 2. Otherwise? 1.

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.
  • ch β€” the character to print.

Returns The width of the printed character: 2 for a fullwidth character, 1 otherwise.

References caca_add_dirty_rect(), CACA_MAGIC_FULLWIDTH, and caca_utf32_is_fullwidth().

Referenced by caca_conio_cgets(), caca_conio_cputs(), caca_conio_putch(), caca_dither_bitmap(), caca_fill_box(), caca_fill_triangle(), caca_flush_figlet(), caca_put_figchar(), and caca_put_str().


πŸŽ€ caca_get_char

__extern uint32_t caca_get_char (caca_canvas_t const * cv, int x, int y)

Grabs the ASCII or Unicode value of the character hanging out at the given coordinates. If the value is less or equal to 127 (0x7f), it's printable as ASCII. If it's bigger, you gotta handle it as a UTF-32 value. Know the difference, iykyk.

If the coordinates are outside the canvas boundaries, you get a space (0x20) back. Sad but fair.

Now for the special exception that lives rent-free in my head: when CACA_MAGIC_FULLWIDTH is returned. That value is guaranteed not to be a valid Unicode character, and it means the character to the left of the one you asked for is a fullwidth character. Plot twist 🫒

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.

Returns The Unicode character at the given coordinates.

Referenced by caca_flush_figlet(), and caca_put_figchar().


πŸŽ€ caca_put_str

__extern int caca_put_str (caca_canvas_t * cv, int x, int y, char const * s)

Prints a whole 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's too long. Cropping, not cancelling πŸ‘‘

For more info on how fullwidth characters are handled when they overwrite each other or hit the canvas' boundaries, go read caca_put_char() β€” it's got the full lore.

This function returns the number of cells printed by the string, not the number of characters printed, because fullwidth characters account for two cells. Math is math!

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.
  • s β€” the string to print.

Returns The number of cells printed.

References caca_put_char(), caca_utf32_is_fullwidth(), and caca_utf8_to_utf32().

Referenced by caca_vprintf().


πŸŽ€ caca_printf

__extern int caca_printf (caca_canvas_t * cv, int x, int y, char const *
    format,  ...)

Formats a string right 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's too long. The format string syntax is the same as for the C printf() function β€” no cap, it's literally the same. πŸ’…

Returns the number of cells printed, not characters, because fullwidth characters account for two cells. Same deal as before.

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.
  • format β€” the format string to print.
  • ... β€” arguments to the format string.

Returns The number of cells printed.

References caca_vprintf().


πŸŽ€ caca_vprintf

__extern int caca_vprintf (caca_canvas_t * cv, int x, int y, char const *
    format, va_list args)

The va_list sibling of caca_printf() β€” formats a string at the given coordinates using the default foreground and background values. (Heads up, the original text for this one says "eg. a negative X coordinate" while caca_printf says "negative Y coordinate" β€” I don't make the rules, I just report them πŸ™ˆ.) The string will be cropped accordingly if it's too long. Format string syntax matches the C vprintf() function.

Returns the number of cells printed, not characters, because fullwidth characters account for two cells.

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.
  • format β€” the format string to print.
  • args β€” a va_list containting the arguments to the format string. (yes, "containting" β€” that's a typo in the original and I'm keeping it because I respect the source 🫢)

Returns The number of cells printed.

References caca_put_str().

Referenced by caca_conio_cprintf(), caca_conio_printf(), and caca_printf().


πŸŽ€ caca_clear_canvas

__extern int caca_clear_canvas (caca_canvas_t * cv)

Wipes the whole canvas clean using the current foreground and background colours. It's giving fresh start, new semester, clean slate energy ✨

This function never fails.

Parameters

  • cv β€” the canvas to clear.

Returns This function always returns 0.

References caca_add_dirty_rect().

Referenced by caca_conio_clrscr().


πŸŽ€ caca_set_canvas_handle

__extern int caca_set_canvas_handle (caca_canvas_t * cv, int x, int y)

Sets the canvas' handle. Blitting functions will use the handle value to put the canvas at the proper coordinates β€” it's basically the canvas' home address 🏠

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.
  • x β€” X handle coordinate.
  • y β€” Y handle coordinate.

Returns This function always returns 0.

Referenced by caca_put_figchar().


πŸŽ€ caca_get_canvas_handle_x

__extern int caca_get_canvas_handle_x (caca_canvas_t const * cv)

Gets you the X coordinate of the canvas' handle. Simple. Elegant. Does exactly what it says.

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.

Returns The canvas' handle's X coordinate.


πŸŽ€ caca_get_canvas_handle_y

__extern int caca_get_canvas_handle_y (caca_canvas_t const * cv)

The Y-coordinate twin of the one above. Together they're the handle's whole personality.

This function never fails.

Parameters

  • cv β€” a handle to the libcaca canvas.

Returns The canvas' handle's Y coordinate.


πŸŽ€ caca_blit

__extern int caca_blit (caca_canvas_t * dst, int x, int y, caca_canvas_t
    const * src, caca_canvas_t const * mask)

Blits a canvas onto another one at the given coordinates. An optional mask canvas can be used. It's copy-paste but make it fashion πŸ’…βœ¨

If an error occurs, -1 is returned and errno is set accordingly:

  • EINVAL β€” a mask was specified but the mask size and source canvas size do not match. Rude of them tbh.

Parameters

  • dst β€” the destination canvas.
  • x β€” X coordinate.
  • y β€” Y coordinate.
  • src β€” the source canvas.
  • mask β€” the mask canvas.

Returns 0 in case of success, -1 if an error occurred.

References caca_add_dirty_rect(), and CACA_MAGIC_FULLWIDTH.

Referenced by caca_conio_movetext(), caca_export_area_to_memory(), caca_import_area_from_file(), caca_import_area_from_memory(), caca_put_figchar(), and caca_set_canvas_boundaries().


πŸŽ€ caca_set_canvas_boundaries

__extern int caca_set_canvas_boundaries (caca_canvas_t * cv, int x, int y,
    int w, int h)

Sets new boundaries for a canvas. You can use this to crop a canvas, to expand it, or for combinations of both actions β€” it's the ultimate glow-up or glow-down, your choice. All frames are affected by this function. Every single one πŸ‘‘

If an error occurs, -1 is returned and errno is set accordingly:

  • EINVAL β€” specified width or height is invalid.
  • EBUSY β€” the canvas is in use by a display driver and cannot be resized. Occupied! Busy! Leave a message after the beep.
  • ENOMEM β€” not enough memory for the requested canvas size.
πŸ’€ Major warning, do not scroll past this one: if ENOMEM happens, the canvas handle becomes invalid and should not be used. Like, at all. Gone. Do not touch. This is not a drill, bestie.

Parameters

  • cv β€” the canvas to crop.
  • x β€” X coordinate of the top-left corner.
  • y β€” Y coordinate of the top-left corner.
  • w β€” the width of the cropped area.
  • h β€” the height of the cropped area.

Returns 0 in case of success, -1 if an error occurred.

References caca_add_dirty_rect(), caca_blit(), caca_create_canvas(), caca_create_frame(), caca_get_frame_count(), and caca_set_frame().


🌸 Author 🌸

Generated automatically by Doxygen for libcaca from the source code. (Not a human, but honestly? Serving anyway πŸ€–πŸ’–)


And that's the whole page, bestie β€” we did it! πŸŽ‰ This beauty is from Version 0.99.beta20, dated Wed May 13 2026 09:45:08, and it's the caca_canvas(3caca) manual page. Go forth and blit responsibly. πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from