libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

libcaca canvas transformation

These functions perform horizontal and vertical canvas flipping. More...

Functions

int caca_invert (caca_canvas_t *)
 Invert a canvas' colours. More...
 
int caca_flip (caca_canvas_t *)
 Flip a canvas horizontally. More...
 
int caca_flop (caca_canvas_t *)
 Flip a canvas vertically. More...
 
int caca_rotate_180 (caca_canvas_t *)
 Rotate a canvas. More...
 
int caca_rotate_left (caca_canvas_t *)
 Rotate a canvas, 90 degrees counterclockwise. More...
 
int caca_rotate_right (caca_canvas_t *)
 Rotate a canvas, 90 degrees counterclockwise. More...
 
int caca_stretch_left (caca_canvas_t *)
 Rotate and stretch a canvas, 90 degrees counterclockwise. More...
 
int caca_stretch_right (caca_canvas_t *)
 Rotate and stretch a canvas, 90 degrees clockwise. More...
 

Detailed Description

These functions perform horizontal and vertical canvas flipping.

Function Documentation

◆ caca_flip()

int caca_flip ( caca_canvas_t )

Flip a canvas horizontally.

Flip a canvas horizontally, choosing characters that look like the mirrored version wherever possible. Some characters will stay unchanged by the process, but the operation is guaranteed to be involutive: performing it again gives back the original canvas.

This function never fails.

Parameters
cvThe canvas to flip.
Returns
This function always returns 0.

< Used to indicate that the previous character was a fullwidth glyph.

< Used to indicate that the previous character was a fullwidth glyph.

Definition at line 73 of file transform.c.

References caca_canvas::attrs, caca_add_dirty_rect(), CACA_MAGIC_FULLWIDTH, caca_canvas::chars, cv, caca_canvas::dirty_disabled, flipchar(), caca_canvas::height, caca_canvas::width, and y.

Referenced by Canvas::Flip(), and Java_org_zoy_caca_Canvas_flipCanvas().

◆ caca_flop()

int caca_flop ( caca_canvas_t )

Flip a canvas vertically.

Flip a canvas vertically, choosing characters that look like the mirrored version wherever possible. Some characters will stay unchanged by the process, but the operation is guaranteed to be involutive: performing it again gives back the original canvas.

This function never fails.

Parameters
cvThe canvas to flop.
Returns
This function always returns 0.

Definition at line 135 of file transform.c.

References caca_canvas::attrs, caca_add_dirty_rect(), caca_canvas::chars, cv, caca_canvas::dirty_disabled, flopchar(), caca_canvas::height, caca_canvas::width, and x.

Referenced by Canvas::Flop(), and Java_org_zoy_caca_Canvas_flopCanvas().

◆ caca_invert()

int caca_invert ( caca_canvas_t )

Invert a canvas' colours.

Invert a canvas' colours (black becomes white, red becomes cyan, etc.) without changing the characters in it.

This function never fails.

Parameters
cvThe canvas to invert.
Returns
This function always returns 0.

Definition at line 44 of file transform.c.

References caca_canvas::attrs, caca_add_dirty_rect(), cv, caca_canvas::dirty_disabled, caca_canvas::height, and caca_canvas::width.

Referenced by Canvas::Invert(), and Java_org_zoy_caca_Canvas_invertCanvas().

◆ caca_rotate_180()

int caca_rotate_180 ( caca_canvas_t )

Rotate a canvas.

Apply a 180-degree transformation to a canvas, choosing characters that look like the upside-down version wherever possible. Some characters will stay unchanged by the process, but the operation is guaranteed to be involutive: performing it again gives back the original canvas.

This function never fails.

Parameters
cvThe canvas to rotate.
Returns
This function always returns 0.

< Used to indicate that the previous character was a fullwidth glyph.

< Used to indicate that the previous character was a fullwidth glyph.

Definition at line 184 of file transform.c.

References caca_canvas::attrs, caca_add_dirty_rect(), CACA_MAGIC_FULLWIDTH, caca_canvas::chars, cv, caca_canvas::dirty_disabled, caca_canvas::height, rotatechar(), caca_canvas::width, and y.

Referenced by cucul_rotate(), Java_org_zoy_caca_Canvas_rotateCanvas180(), and Canvas::Rotate180().

◆ caca_rotate_left()

int caca_rotate_left ( caca_canvas_t )

Rotate a canvas, 90 degrees counterclockwise.

Apply a 90-degree transformation to a canvas, choosing characters that look like the rotated version wherever possible. Characters cells are rotated two-by-two. Some characters will stay unchanged by the process, some others will be replaced by close equivalents. Fullwidth characters at odd horizontal coordinates will be lost. The operation is not guaranteed to be reversible at all.

Note that the width of the canvas is divided by two and becomes the new height. Height is multiplied by two and becomes the new width. If the original width is an odd number, the division is rounded up.

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

  • EBUSY The canvas is in use by a display driver and cannot be rotated.
  • ENOMEM Not enough memory to allocate the new canvas size. If this happens, the previous canvas handle is still valid.
Parameters
cvThe canvas to rotate left.
Returns
0 in case of success, -1 if an error occurred.

Definition at line 255 of file transform.c.

References _caca_load_frame_info(), _caca_save_frame_info(), caca_frame::attrs, caca_canvas::attrs, caca_add_dirty_rect(), caca_frame::chars, caca_canvas::chars, cv, caca_canvas::dirty_disabled, caca_canvas::frame, caca_canvas::frames, caca_frame::handlex, caca_frame::handley, caca_frame::height, caca_canvas::height, leftpair(), caca_canvas::refcount, seterrno, caca_frame::width, caca_canvas::width, x, caca_frame::x, y, and caca_frame::y.

Referenced by Java_org_zoy_caca_Canvas_rotateCanvasLeft(), and Canvas::RotateLeft().

◆ caca_rotate_right()

int caca_rotate_right ( caca_canvas_t )

Rotate a canvas, 90 degrees counterclockwise.

Apply a 90-degree transformation to a canvas, choosing characters that look like the rotated version wherever possible. Characters cells are rotated two-by-two. Some characters will stay unchanged by the process, some others will be replaced by close equivalents. Fullwidth characters at odd horizontal coordinates will be lost. The operation is not guaranteed to be reversible at all.

Note that the width of the canvas is divided by two and becomes the new height. Height is multiplied by two and becomes the new width. If the original width is an odd number, the division is rounded up.

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

  • EBUSY The canvas is in use by a display driver and cannot be rotated.
  • ENOMEM Not enough memory to allocate the new canvas size. If this happens, the previous canvas handle is still valid.
Parameters
cvThe canvas to rotate right.
Returns
0 in case of success, -1 if an error occurred.

Definition at line 375 of file transform.c.

References _caca_load_frame_info(), _caca_save_frame_info(), caca_frame::attrs, caca_canvas::attrs, caca_add_dirty_rect(), caca_frame::chars, caca_canvas::chars, cv, caca_canvas::dirty_disabled, caca_canvas::frame, caca_canvas::frames, caca_frame::handlex, caca_frame::handley, caca_frame::height, caca_canvas::height, caca_canvas::refcount, rightpair(), seterrno, caca_frame::width, caca_canvas::width, x, caca_frame::x, y, and caca_frame::y.

Referenced by Java_org_zoy_caca_Canvas_rotateCanvasRight(), and Canvas::RotateRight().

◆ caca_stretch_left()

int caca_stretch_left ( caca_canvas_t )

Rotate and stretch a canvas, 90 degrees counterclockwise.

Apply a 90-degree transformation to a canvas, choosing characters that look like the rotated version wherever possible. Some characters will stay unchanged by the process, some others will be replaced by close equivalents. Fullwidth characters will be lost. The operation is not guaranteed to be reversible at all.

Note that the width and height of the canvas are swapped, causing its aspect ratio to look stretched.

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

  • EBUSY The canvas is in use by a display driver and cannot be rotated.
  • ENOMEM Not enough memory to allocate the new canvas size. If this happens, the previous canvas handle is still valid.
Parameters
cvThe canvas to rotate left.
Returns
0 in case of success, -1 if an error occurred.

Definition at line 493 of file transform.c.

References _caca_load_frame_info(), _caca_save_frame_info(), caca_frame::attrs, caca_canvas::attrs, caca_add_dirty_rect(), caca_frame::chars, caca_canvas::chars, cv, caca_canvas::frame, caca_canvas::frames, caca_frame::handlex, caca_frame::handley, caca_frame::height, caca_canvas::height, leftchar(), caca_canvas::refcount, seterrno, caca_frame::width, caca_canvas::width, x, caca_frame::x, y, and caca_frame::y.

Referenced by Java_org_zoy_caca_Canvas_stretchCanvasLeft().

◆ caca_stretch_right()

int caca_stretch_right ( caca_canvas_t )

Rotate and stretch a canvas, 90 degrees clockwise.

Apply a 270-degree transformation to a canvas, choosing characters that look like the rotated version wherever possible. Some characters will stay unchanged by the process, some others will be replaced by close equivalents. Fullwidth characters will be lost. The operation is not guaranteed to be reversible at all.

Note that the width and height of the canvas are swapped, causing its aspect ratio to look stretched.

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

  • EBUSY The canvas is in use by a display driver and cannot be rotated.
  • ENOMEM Not enough memory to allocate the new canvas size. If this happens, the previous canvas handle is still valid.
Parameters
cvThe canvas to rotate right.
Returns
0 in case of success, -1 if an error occurred.

Definition at line 586 of file transform.c.

References _caca_load_frame_info(), _caca_save_frame_info(), caca_frame::attrs, caca_canvas::attrs, caca_add_dirty_rect(), caca_frame::chars, caca_canvas::chars, cv, caca_canvas::frame, caca_canvas::frames, caca_frame::handlex, caca_frame::handley, caca_frame::height, caca_canvas::height, caca_canvas::refcount, rightchar(), seterrno, caca_frame::width, caca_canvas::width, x, caca_frame::x, y, and caca_frame::y.

Referenced by Java_org_zoy_caca_Canvas_stretchCanvasRight().