Top |
ChafaCanvasConfigChafaCanvasConfig — Describes a configuration for ChafaCanvas |
enum | ChafaPixelMode |
enum | ChafaColorSpace |
enum | ChafaCanvasMode |
enum | ChafaDitherMode |
enum | ChafaColorExtractor |
enum | ChafaOptimizations |
enum | ChafaPassthrough |
typedef | ChafaCanvasConfig |
A ChafaCanvasConfig describes a set of parameters for ChafaCanvas, such as its geometry, color space and other output characteristics.
To create a new ChafaCanvasConfig, use chafa_canvas_config_new()
. You
can then modify it using its setters, e.g. chafa_canvas_config_set_canvas_mode()
before assigning it to a new ChafaCanvas with chafa_canvas_new()
.
Note that it is not possible to change a canvas' configuration after the canvas is created.
ChafaCanvasConfig *
chafa_canvas_config_new (void
);
Creates a new ChafaCanvasConfig with default settings. This object can later be used in the creation of a ChafaCanvas.
ChafaCanvasConfig *
chafa_canvas_config_copy (const ChafaCanvasConfig *config
);
Creates a new ChafaCanvasConfig that's a copy of config
.
void
chafa_canvas_config_ref (ChafaCanvasConfig *config
);
Adds a reference to config
.
void
chafa_canvas_config_unref (ChafaCanvasConfig *config
);
Removes a reference from config
.
void chafa_canvas_config_get_geometry (const ChafaCanvasConfig *config
,gint *width_out
,gint *height_out
);
Returns config
's width and height in character cells in the
provided output locations.
void chafa_canvas_config_set_geometry (ChafaCanvasConfig *config
,gint width
,gint height
);
Sets config
's width and height in character cells to width
x height
.
void chafa_canvas_config_get_cell_geometry (const ChafaCanvasConfig *config
,gint *cell_width_out
,gint *cell_height_out
);
Returns config
's cell width and height in pixels in the
provided output locations.
Since: 1.4
void chafa_canvas_config_set_cell_geometry (ChafaCanvasConfig *config
,gint cell_width
,gint cell_height
);
Sets config
's cell width and height in pixels to cell_width
x cell_height
.
Since: 1.4
ChafaPixelMode
chafa_canvas_config_get_pixel_mode (const ChafaCanvasConfig *config
);
Returns config
's ChafaPixelMode.
Since: 1.4
void chafa_canvas_config_set_pixel_mode (ChafaCanvasConfig *config
,ChafaPixelMode pixel_mode
);
Sets config
's stored ChafaPixelMode to pixel_mode
. This determines
how pixel graphics are rendered in the output.
Since: 1.4
ChafaCanvasMode
chafa_canvas_config_get_canvas_mode (const ChafaCanvasConfig *config
);
Returns config
's ChafaCanvasMode. This determines how colors (and
color control codes) are used in the output.
void chafa_canvas_config_set_canvas_mode (ChafaCanvasConfig *config
,ChafaCanvasMode mode
);
Sets config
's stored ChafaCanvasMode to mode
. This determines how
colors (and color control codes) are used in the output.
ChafaColorExtractor
chafa_canvas_config_get_color_extractor
(const ChafaCanvasConfig *config
);
Returns config
's ChafaColorExtractor. This determines how colors are
approximated in character symbol output.
Since: 1.4
void chafa_canvas_config_set_color_extractor (ChafaCanvasConfig *config
,ChafaColorExtractor color_extractor
);
Sets config
's stored ChafaColorExtractor to color_extractor
. This
determines how colors are approximated in character symbol output.
Since: 1.4
ChafaColorSpace
chafa_canvas_config_get_color_space (const ChafaCanvasConfig *config
);
Returns config
's ChafaColorSpace.
void chafa_canvas_config_set_color_space (ChafaCanvasConfig *config
,ChafaColorSpace color_space
);
Sets config
's stored ChafaColorSpace to color_space
.
gboolean
chafa_canvas_config_get_preprocessing_enabled
(const ChafaCanvasConfig *config
);
Queries whether automatic image preprocessing is enabled. This allows Chafa to boost contrast and saturation in an attempt to improve legibility. The type of preprocessing applied (if any) depends on the canvas mode.
void chafa_canvas_config_set_preprocessing_enabled (ChafaCanvasConfig *config
,gboolean preprocessing_enabled
);
Indicates whether automatic image preprocessing should be enabled. This allows Chafa to boost contrast and saturation in an attempt to improve legibility. The type of preprocessing applied (if any) depends on the canvas mode.
const ChafaSymbolMap *
chafa_canvas_config_peek_symbol_map (const ChafaCanvasConfig *config
);
Returns a pointer to the symbol map belonging to config
.
This can be inspected using the ChafaSymbolMap getter
functions, but not changed.
void chafa_canvas_config_set_symbol_map (ChafaCanvasConfig *config
,const ChafaSymbolMap *symbol_map
);
Assigns a copy of symbol_map
to config
.
const ChafaSymbolMap *
chafa_canvas_config_peek_fill_symbol_map
(const ChafaCanvasConfig *config
);
Returns a pointer to the fill symbol map belonging to config
.
This can be inspected using the ChafaSymbolMap getter
functions, but not changed.
Fill symbols are assigned according to their overall foreground to background coverage, disregarding shape.
void chafa_canvas_config_set_fill_symbol_map (ChafaCanvasConfig *config
,const ChafaSymbolMap *fill_symbol_map
);
Assigns a copy of fill_symbol_map
to config
.
gfloat
chafa_canvas_config_get_transparency_threshold
(const ChafaCanvasConfig *config
);
Returns the threshold above which full transparency will be used.
void chafa_canvas_config_set_transparency_threshold (ChafaCanvasConfig *config
,gfloat alpha_threshold
);
Sets the threshold above which full transparency will be used.
gboolean
chafa_canvas_config_get_fg_only_enabled
(const ChafaCanvasConfig *config
);
Queries whether to use foreground colors only, leaving the background unmodified in the canvas output. This is relevant only when the ChafaPixelMode is set to CHAFA_PIXEL_MODE_SYMBOLS.
When this is set, the canvas will emit escape codes to set the foreground color only.
Since: 1.8
void chafa_canvas_config_set_fg_only_enabled (ChafaCanvasConfig *config
,gboolean fg_only_enabled
);
Indicates whether to use foreground colors only, leaving the background unmodified in the canvas output. This is relevant only when the ChafaPixelMode is set to CHAFA_PIXEL_MODE_SYMBOLS.
When this is set, the canvas will emit escape codes to set the foreground color only.
Since: 1.8
guint32
chafa_canvas_config_get_fg_color (const ChafaCanvasConfig *config
);
Gets the assumed foreground color of the output device. This is used to determine how to apply the foreground pen in FGBG modes.
void chafa_canvas_config_set_fg_color (ChafaCanvasConfig *config
,guint32 fg_color_packed_rgb
);
Sets the assumed foreground color of the output device. This is used to determine how to apply the foreground pen in FGBG modes.
guint32
chafa_canvas_config_get_bg_color (const ChafaCanvasConfig *config
);
Gets the assumed background color of the output device. This is used to determine how to apply the background pen in FGBG modes.
void chafa_canvas_config_set_bg_color (ChafaCanvasConfig *config
,guint32 bg_color_packed_rgb
);
Sets the assumed background color of the output device. This is used to determine how to apply the background and transparency pens in FGBG modes, and will also be substituted for partial transparency.
gfloat
chafa_canvas_config_get_work_factor (const ChafaCanvasConfig *config
);
Gets the work/quality tradeoff factor. A higher value means more time and memory will be spent towards a higher quality output.
void chafa_canvas_config_set_work_factor (ChafaCanvasConfig *config
,gfloat work_factor
);
Sets the work/quality tradeoff factor. A higher value means more time and memory will be spent towards a higher quality output.
ChafaDitherMode
chafa_canvas_config_get_dither_mode (const ChafaCanvasConfig *config
);
Returns config
's ChafaDitherMode.
Since: 1.2
void chafa_canvas_config_set_dither_mode (ChafaCanvasConfig *config
,ChafaDitherMode dither_mode
);
Sets config
's stored ChafaDitherMode to dither_mode
.
Since: 1.2
void chafa_canvas_config_get_dither_grain_size (const ChafaCanvasConfig *config
,gint *width_out
,gint *height_out
);
Returns config
's dither grain size in width_out
and height_out
.
config |
||
width_out |
Pointer to a location to store grain width |
|
height_out |
Pointer to a location to store grain height |
Since: 1.2
void chafa_canvas_config_set_dither_grain_size (ChafaCanvasConfig *config
,gint width
,gint height
);
Sets config
's stored dither grain size to width
by height
pixels. These
values can be 1, 2, 4 or 8. 8 corresponds to the size of an entire
character cell. The default is 4 pixels by 4 pixels.
config |
||
width |
The desired grain width (1, 2, 4 or 8) |
|
height |
The desired grain height (1, 2, 4 or 8) |
Since: 1.2
gfloat
chafa_canvas_config_get_dither_intensity
(const ChafaCanvasConfig *config
);
Returns the relative intensity of the dithering pattern applied during image conversion. 1.0 is the default, corresponding to a moderate intensity.
Since: 1.2
void chafa_canvas_config_set_dither_intensity (ChafaCanvasConfig *config
,gfloat intensity
);
Sets config
's stored relative intensity of the dithering pattern applied
during image conversion. 1.0 is the default, corresponding to a moderate
intensity. Possible values range from 0.0 to infinity, but in practice,
values above 10.0 are rarely useful.
Since: 1.2
ChafaOptimizations
chafa_canvas_config_get_optimizations (const ChafaCanvasConfig *config
);
Returns config
's optimization flags. When enabled, these may produce
more compact output at the cost of reduced compatibility and increased CPU
use. Output quality is unaffected.
Since: 1.6
void chafa_canvas_config_set_optimizations (ChafaCanvasConfig *config
,ChafaOptimizations optimizations
);
Sets config
's stored optimization flags. When enabled, these may produce
more compact output at the cost of reduced compatibility and increased CPU
use. Output quality is unaffected.
Since: 1.6
ChafaPassthrough
chafa_canvas_config_get_passthrough (const ChafaCanvasConfig *config
);
Returns config
's ChafaPassthrough setting. This defaults to
CHAFA_PASSTHROUGH_NONE.
Passthrough is needed to transmit certain escape codes to the outer terminal when running in an inner terminal environment like tmux. When enabled, this will happen automatically as needed, dictated by information contained in a ChafaTermInfo.
Since: 1.14
void chafa_canvas_config_set_passthrough (ChafaCanvasConfig *config
,ChafaPassthrough passthrough
);
Indicates which passthrough mode to use. This defaults to CHAFA_PASSTHROUGH_NONE.
Passthrough is needed to transmit certain escape codes to the outer terminal when running in an inner terminal environment like tmux. When enabled, this will happen automatically as needed, dictated by information contained in a ChafaTermInfo.
Since: 1.14
Truecolor. |
||
256 colors. |
||
256 colors, but avoid using the lower 16 whose values vary between terminal environments. |
||
16 colors using the aixterm ANSI extension. |
||
Default foreground and background colors, plus inversion. |
||
Default foreground and background colors. No ANSI codes will be used. |
||
8 colors, compatible with original ANSI X3.64. |
||
16 FG colors (8 of which enabled with bold/bright) and 8 BG colors. |
||
Last supported canvas mode plus one. |