![]() |
![]() |
![]() |
![]() |
A ChafaCanvas is a canvas that can render its contents as text strings.
To create a new ChafaCanvas, use chafa_canvas_new()
. If you want to
specify any parameters, like the geometry, color space and so on, you
must create a ChafaCanvasConfig first.
You can draw an image to the canvas using chafa_canvas_set_contents_rgba8()
and create an ANSI text representation of the canvas' current contents
using chafa_canvas_build_ansi()
.
ChafaCanvas *
chafa_canvas_new (const ChafaCanvasConfig *config
);
Creates a new canvas with the specified configuration. The canvas makes a private copy of the configuration, so it will not be affected by subsequent changes.
ChafaCanvas *
chafa_canvas_new_similar (ChafaCanvas *orig
);
Creates a new canvas configured similarly to orig
.
void
chafa_canvas_unref (ChafaCanvas *canvas
);
Removes a reference from canvas
. When remaining references drops to
zero, the canvas is freed and can no longer be used.
const ChafaCanvasConfig *
chafa_canvas_peek_config (ChafaCanvas *canvas
);
Returns a pointer to the configuration belonging to canvas
.
This can be inspected using the ChafaCanvasConfig getter
functions, but not changed.
void chafa_canvas_set_contents_rgba8 (ChafaCanvas *canvas
,const guint8 *src_pixels
,gint src_width
,gint src_height
,gint src_rowstride
);
Replaces pixel data of canvas
with a copy of that found at src_pixels
.
The source data must be in packed 8-bits-per-channel RGBA format. The
alpha value is expressed as opacity (0xff is opaque) and is not
premultiplied.
GString *
chafa_canvas_build_ansi (ChafaCanvas *canvas
);
Builds a UTF-8 string of ANSI sequences and symbols representing
the canvas' current contents. This can e.g. be printed to a terminal.
The exact choice of escape sequences and symbols, dimensions, etc. is
determined by the configuration assigned to canvas
on its creation.
All output lines except for the last one will end in a newline.