Raxol.Terminal.ANSI.SixelGraphics (Raxol v0.5.0)
View SourceSixel graphics support for terminal rendering.
This module handles:
- Sixel image encoding and decoding
- Color palette management
- Image scaling and positioning
- Terminal compatibility checks
Summary
Functions
Decodes an ANSI escape sequence into a Sixel image.
Encodes a Sixel image to ANSI escape sequence.
Gets the current image data.
Gets the current color palette.
Gets the current position.
Gets the current scale factors.
Creates a new Sixel image with default values.
Creates a new Sixel image with specified dimensions.
Processes a sequence of Sixel data.
Sets the image data for a Sixel image.
Sets the color palette for a Sixel image.
Sets the position for a Sixel image.
Sets the scale factor for a Sixel image.
Checks if the terminal supports Sixel graphics.
Types
@type t() :: %Raxol.Terminal.ANSI.SixelGraphics{ attributes: map(), current_color: non_neg_integer(), data: binary(), height: non_neg_integer(), palette: map(), pixel_buffer: map(), position: {non_neg_integer(), non_neg_integer()}, scale: {non_neg_integer(), non_neg_integer()}, sixel_cursor_pos: {non_neg_integer(), non_neg_integer()}, width: non_neg_integer() }
Functions
Decodes an ANSI escape sequence into a Sixel image.
Parameters
data
- The ANSI escape sequence to decode
Returns
A new Raxol.Terminal.ANSI.SixelGraphics.t/0
struct with the decoded image data.
Encodes a Sixel image to ANSI escape sequence.
Parameters
image
- The image to encode
Returns
A binary containing the ANSI escape sequence for the Sixel image.
Gets the current image data.
Parameters
image
- The current image
Returns
The binary image data.
Gets the current color palette.
Parameters
image
- The current image
Returns
A map containing the current color palette.
@spec get_position(t()) :: {non_neg_integer(), non_neg_integer()}
Gets the current position.
Parameters
image
- The current image
Returns
A tuple {x, y}
with the current position.
@spec get_scale(t()) :: {non_neg_integer(), non_neg_integer()}
Gets the current scale factors.
Parameters
image
- The current image
Returns
A tuple {x_scale, y_scale}
with the current scale factors.
@spec new() :: t()
Creates a new Sixel image with default values.
Returns
A new Raxol.Terminal.ANSI.SixelGraphics.t/0
struct with default values.
@spec new(non_neg_integer(), non_neg_integer()) :: t()
Creates a new Sixel image with specified dimensions.
Parameters
width
- The image width in pixelsheight
- The image height in pixels
Returns
A new Raxol.Terminal.ANSI.SixelGraphics.t/0
struct with the specified dimensions.
Processes a sequence of Sixel data.
Parameters
state
- The current Sixel statedata
- The Sixel data to process
Returns
A tuple containing the updated state and a response.
Sets the image data for a Sixel image.
Parameters
image
- The current imagedata
- The binary image data
Returns
The updated image with new data.
Sets the color palette for a Sixel image.
Parameters
image
- The current imagepalette
- A map of color indices to RGB values
Returns
The updated image with new palette.
@spec set_position(t(), non_neg_integer(), non_neg_integer()) :: t()
Sets the position for a Sixel image.
Parameters
image
- The current imagex
- The horizontal positiony
- The vertical position
Returns
The updated image with new position.
@spec set_scale(t(), non_neg_integer(), non_neg_integer()) :: t()
Sets the scale factor for a Sixel image.
Parameters
image
- The current imagex_scale
- The horizontal scale factory_scale
- The vertical scale factor
Returns
The updated image with new scale factors.
@spec supported?() :: boolean()
Checks if the terminal supports Sixel graphics.
Returns
true
if Sixel graphics are supported, false
otherwise.