constixel
Loading...
Searching...
No Matches
constixel::image< T, W, H, GRAYSCALE, USE_SPAN > Class Template Reference

Core class of constixel. Holds a buffer of an image width a certain size and format. Typical use: More...

#include <constixel.hpp>

Public Member Functions

 image ()=default
 Creates a new image with internal storage.
 
 image (const std::span< uint8_t, T< W, H, GRAYSCALE, USE_SPAN >::image_size > &other)
 When USE_SPAN=true creates a new image with external storage based existing std::span.
 
constexpr void clear ()
 Clear the image by setting everything to zero.
 
constexpr std::array< uint8_t, T< W, H, GRAYSCALE, USE_SPAN >::image_size > & data_ref ()
 Get a reference to the underlying raw data of the image.
 
constexpr image< T, W, H, GRAYSCALE > clone () const
 Returns a clone of this image. Data is copied.
 
constexpr void copy (const image< T, W, H, GRAYSCALE > &src)
 Copy source image into this instance. No compositing occurs, replaces current content.
 
template<size_t BYTE_SIZE>
constexpr void copy (const uint8_t *src)
 Copy raw source data into this instance. No compositing occurs.
 
constexpr uint8_t get_nearest_color (uint8_t r, uint8_t g, uint8_t b) const
 Return closest match in the color palette based on the supplied red, green and blue values.
 
constexpr void plot (int32_t x, int32_t y, uint8_t col)
 Plot a single pixel at the specified coordinates using the supplied color.
 
constexpr void plot (const struct plot &p)
 Plot a single pixel at the specified coordinates using the supplied color.
 
constexpr void draw_line (int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint8_t col, int32_t stroke_width=1)
 Draw a line with the specified color and thickness. Example:
 
constexpr void draw_line (const struct draw_line &d)
 Draw a line with the specified color and thickness. Example:
 
constexpr void draw_line_aa (int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint8_t col, float stroke_width=1.0f)
 Draw an antialiased line with variable stroke width. Only format_8bit targets are supported. Example:
 
constexpr void draw_line_aa (const struct draw_line &d)
 Draw a 1-pixel wide antialiased line with the specified color. Only format_8bit targets are supported. Example:
 
template<typename FONT, bool KERNING = false>
constexpr int32_t string_width (const char *str, size_t character_count=std::numeric_limits< size_t >::max(), size_t *character_actual=nullptr)
 Return the width of a string using the specified font in the template parameter. Typical use:
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr int32_t draw_string_mono (int32_t x, int32_t y, const char *str, uint8_t col, size_t character_count=std::numeric_limits< size_t >::max(), size_t *character_actual=nullptr)
 Draw text at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr int32_t draw_string_mono (const struct draw_string &d, size_t character_count=std::numeric_limits< size_t >::max(), size_t *character_actual=nullptr)
 Draw text at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr void draw_string_centered_mono (int32_t x, int32_t y, const char *str, uint8_t col)
 Draw text centered at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr int32_t draw_string_aa (int32_t x, int32_t y, const char *str, uint8_t col, size_t character_count=std::numeric_limits< size_t >::max(), size_t *character_actual=nullptr)
 Draw antialiased text at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use:
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr int32_t draw_string_aa (const struct draw_string &d, size_t character_count=std::numeric_limits< size_t >::max(), size_t *character_actual=nullptr)
 Draw antialiased text at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use:
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr void draw_string_centered_aa (int32_t x, int32_t y, const char *str, uint8_t col)
 Draw antialiased text centered at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use.
 
constexpr void fill_rect (int32_t x, int32_t y, int32_t w, int32_t h, uint8_t col)
 Fill a rectangle with the specified color. Example:
 
constexpr void fill_rect (const struct draw_rect &d)
 Fill a rectangle with the specified color. Example:
 
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
constexpr auto fill_rect (int32_t x, int32_t y, int32_t w, int32_t h, const shader_func &shader) -> void
 Fill a rectangle with a shader function that generates colors per pixel.
 
constexpr void stroke_rect (int32_t x, int32_t y, int32_t w, int32_t h, uint8_t col, int32_t stroke_width=1)
 Draw a stroked rectangle with the specified color and stroke width. Example:
 
constexpr void stroke_rect (const struct draw_rect &d)
 Draw a stroked rectangle with the specified color and stroke width. Example:
 
constexpr void fill_circle (int32_t cx, int32_t cy, int32_t radius, uint8_t col)
 Fill a circle with the specified radius and color. Example:
 
constexpr void fill_circle (const struct draw_circle &d)
 Fill a circle with the specified radius and color. Example:
 
constexpr void stroke_circle (int32_t cx, int32_t cy, int32_t radius, uint8_t col, int32_t stroke_width=1)
 Stroke a circle with the specified radius and color. Example:
 
constexpr void stroke_circle (const struct draw_circle &d)
 Stroke a circle with the specified radius and color. Example:
 
constexpr void stroke_circle_aa (int32_t cx, int32_t cy, int32_t radius, uint8_t col, int32_t stroke_width=1)
 Stroke a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:
 
constexpr void stroke_circle_aa (const struct draw_circle &d)
 Stroke a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:
 
constexpr void fill_circle_aa (int32_t cx, int32_t cy, int32_t radius, uint8_t col)
 Fill a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:
 
constexpr void fill_circle_aa (const struct draw_circle &d)
 Fill a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:
 
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
constexpr auto fill_circle_aa (int32_t cx, int32_t cy, int32_t radius, const shader_func &shader) -> void
 Fill a circle using antialiasing with a shader function that generates colors per pixel.
 
constexpr void stroke_round_rect (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint8_t col, int32_t stroke_width=1)
 Stroke a rounded rectangle with the specified color. Example:
 
constexpr void stroke_round_rect (const struct draw_round_rect &d)
 Stroke a rounded rectangle with the specified color. Example:
 
constexpr void fill_round_rect (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint8_t col)
 Fill a rounded rectangle with the specified color. Example:
 
constexpr void fill_round_rect (const struct draw_round_rect &d)
 Fill a rounded rectangle with the specified color. Example:
 
constexpr void fill_round_rect_aa (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint8_t col)
 Fill a rounded rectangle using antialiasing with the specified color. Only format_8bit targets are supported. Example:
 
constexpr void fill_round_rect_aa (const struct draw_round_rect &d)
 Fill a rounded rectangle using antialiasing with the specified color. Only format_8bit targets are supported.
 
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
constexpr auto fill_round_rect_aa (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, const shader_func &shader) -> void
 Fill a rounded rectangle using antialiasing with a shader function that generates colors per pixel.
 
constexpr void stroke_round_rect_aa (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint8_t col, int32_t stroke_width=1)
 Stroke a rounded rectangle using antialiasing with the specified color. Example:
 
constexpr void stroke_round_rect_aa (const struct draw_round_rect &d)
 Stroke a rounded rectangle using antialiasing with the specified color. Example:
 
constexpr void RGBA_uint32 (std::array< uint32_t, W *H > &dst) const
 Convert this instance to an equivalent RGBA8 data array.
 
constexpr void RGBA_uint8 (std::array< uint8_t, W *H *4 > &dst) const
 Convert this instance to an equivalent RGBA8 data array.
 
constexpr void flip_h ()
 Flip the contents of this image horizontally.
 
constexpr void flip_v ()
 Flip the contents of this image vertically.
 
constexpr void flip_hv ()
 Flip the contents of this image horizontally & vertically.
 
template<bool FLIP_H = false, bool FLIP_V = false>
constexpr image< T, H, W, GRAYSCALE > transpose () const
 Return a transposed version of this image.
 
template<bool FLIP_H = false, bool FLIP_V = false>
constexpr void transpose (image< T, H, W, GRAYSCALE > &dst) const
 Transpose this image into another.
 
constexpr void blit_RGBA (int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping.
 
constexpr void blit_RGBA (const rect< int32_t > &dstrect, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping.
 
constexpr void blit_RGBA_diffused (int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping. Simple integer based diffusion is applied.
 
constexpr void blit_RGBA_diffused (const rect< int32_t > &dstrect, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping. Simple integer based diffusion is applied.
 
constexpr void blit_RGBA_diffused_linear (int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping. Diffusion in linear color space is applied.
 
constexpr void blit_RGBA_diffused_linear (const rect< int32_t > &dstrect, const uint8_t *ptr, int32_t iw, int32_t ih, int32_t stride)
 Blit an RGBA8 buffer into this instance using brute force color mapping. Diffusion in linear color space is applied.
 
template<typename F>
constexpr void png (F &&char_out) const
 Convert the current instance into a png image. Typically an implementation looks like this:
 
template<size_t S = 1, typename F>
constexpr void sixel (F &&char_out) const
 Convert the current instance into a sixel stream. Typically an implementation looks like this:
 
template<size_t S = 1, typename F>
constexpr void sixel (F &&char_out, const rect< int32_t > &rect) const
 Convert the current instance into a sixel stream. Typically an implementation looks like this:
 
template<size_t S = 1>
void sixel_to_cout () const
 Convert the current instance into a sixel stream and output it to std::cout.
 
void vt100_clear () const
 Send a escape command to std::cout to clear the screen and scroll buffer of a vt100 compatible terminal.
 
void vt100_clear_scrollback () const
 Send a escape command to std::cout to clear the screen and scroll buffer of a vt100 compatible terminal.
 
void vt100_home () const
 Send a escape command to std::cout to home the cursor of a vt100 compatible terminal.
 
void png_to_iterm () const
 Convert the current instance into a png and display it in iTerm.
 
void png_to_kitty () const
 Convert the current instance into a png and display it in a terminal with kitty graphics support.
 
template<device_format dst_format, typename F>
constexpr void convert (F &&uint8_out)
 Convert the current instance into a byte stream formatted for embedded displays.
 
constexpr auto rect (int32_t x, int32_t y, int32_t w, int32_t h)
 Fluent shape API methods for method chaining These provide a more expressive way to create shapes compared to struct-based calls.
 
constexpr auto circle (int32_t cx, int32_t cy, int32_t r)
 Create a circle shape for fluent method chaining.
 
constexpr auto circle_aa (int32_t cx, int32_t cy, int32_t r)
 Create an antialiased circle shape for fluent method chaining. Only format_8bit targets are supported.
 
constexpr auto round_rect (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius)
 Create a rounded rectangle shape for fluent method chaining.
 
constexpr auto round_rect_aa (int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius)
 Create an antialiased rounded rectangle shape for fluent method chaining. Only format_8bit targets are supported.
 
constexpr auto line (int32_t x0, int32_t y0, int32_t x1, int32_t y1)
 Create a line shape for fluent method chaining.
 
constexpr auto line_aa (int32_t x0, int32_t y0, int32_t x1, int32_t y1)
 Create an antialiased line shape for fluent method chaining. Only format_8bit targets are supported.
 
constexpr auto point (int32_t x, int32_t y)
 Create a point shape for fluent method chaining.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr auto text_mono (int32_t x, int32_t y, const char *str)
 Create a text shape for fluent monospace string drawing with method chaining.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr auto text_aa (int32_t x, int32_t y, const char *str)
 Create a text shape for fluent antialiased string drawing with method chaining. Only format_8bit targets are supported.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr auto text_centered_mono (int32_t x, int32_t y, const char *str)
 Create a text shape for fluent centered monospace string drawing with method chaining.
 
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
constexpr auto text_centered_aa (int32_t x, int32_t y, const char *str)
 Create a text shape for fluent centered antialiased string drawing with method chaining. Only format_8bit targets are supported.
 

Static Public Member Functions

static constexpr bool grayscale ()
 Boolean indicating that the palette is grayscale instead of color.
 
static constexpr size_t bit_depth ()
 Bit depth of the image.
 
static constexpr size_t size ()
 Size in bytes of the image data. This does not include the image instance size.
 
static constexpr size_t bytes_per_line ()
 Bytes per line in the image data. Also called stride.
 
static constexpr int32_t width ()
 Width in pixels of the image.
 
static constexpr int32_t height ()
 Height in pixels of the image.
 

Detailed Description

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
class constixel::image< T, W, H, GRAYSCALE, USE_SPAN >

Core class of constixel. Holds a buffer of an image width a certain size and format. Typical use:

Core class of constixel. Holds a buffer of an image width a certain size and format....
Definition constixel.hpp:3502
image()=default
Creates a new image with internal storage.
Template Parameters
TType of the image buffer. One of format_1bit, format_2bit, format_4bit, format_8bit, format_24bit or format_32bit.
WWidth in pixels.
HHeight in pixels.
GRAYSCALEboolean to indicate if palette should be grayscale. Otherwise a colored palette will be used.
USE_SPANPass in your own std::span in the constructor to be used as a back buffer. Defaults to false.

Constructor & Destructor Documentation

◆ image()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::image ( const std::span< uint8_t, T< W, H, GRAYSCALE, USE_SPAN >::image_size > & other)
inline

When USE_SPAN=true creates a new image with external storage based existing std::span.

Parameters
otherIf USE_SPAN=true this constructor will accept a std::span.

Member Function Documentation

◆ bit_depth()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr size_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::bit_depth ( )
inlinestaticnodiscardconstexpr

Bit depth of the image.

Returns
Bit depth of the image. 1 == 2 colors, 2 == 4 colors, 4 == 16 colors, 8 == 256 colors.

◆ blit_RGBA() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA ( const rect< int32_t > & dstrect,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping.

Parameters
dstrectRectangular area in the target buffer to blit into. If the rectangle is smaller than the RGBA8 buffer, clipping occurs.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihWeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ blit_RGBA() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping.

Parameters
xStarting X-coordinate position in the target instance in pixels.
yStarting Y-coordinate position in the target instance in pixels.
wWidth of the rectangle. If the width is smaller than the RGBA8 buffer content will be clipped.
hWeight of the rectangle. If the height is smaller than the RGBA8 buffer content will be clipped.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihHeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ blit_RGBA_diffused() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA_diffused ( const rect< int32_t > & dstrect,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping. Simple integer based diffusion is applied.

Parameters
dstrectRectangular area in the target buffer to blit into. If the rectangle is smaller than the RGBA8 buffer, clipping occurs.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihWeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ blit_RGBA_diffused() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA_diffused ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping. Simple integer based diffusion is applied.

Parameters
xStarting X-coordinate position in the target instance in pixels.
yStarting Y-coordinate position in the target instance in pixels.
wWidth of the rectangle. If the width is smaller than the RGBA8 buffer content will be clipped.
hWeight of the rectangle. If the height is smaller than the RGBA8 buffer content will be clipped.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihHeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ blit_RGBA_diffused_linear() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA_diffused_linear ( const rect< int32_t > & dstrect,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping. Diffusion in linear color space is applied.

Parameters
dstrectRectangular area in the target buffer to blit into. If the rectangle is smaller than the RGBA8 buffer, clipping occurs.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihWeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ blit_RGBA_diffused_linear() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::blit_RGBA_diffused_linear ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
const uint8_t * ptr,
int32_t iw,
int32_t ih,
int32_t stride )
inlineconstexpr

Blit an RGBA8 buffer into this instance using brute force color mapping. Diffusion in linear color space is applied.

Parameters
xStarting X-coordinate position in the target instance in pixels.
yStarting Y-coordinate position in the target instance in pixels.
wWidth of the rectangle. If the width is smaller than the RGBA8 buffer content will be clipped.
hWeight of the rectangle. If the height is smaller than the RGBA8 buffer content will be clipped.
ptrPointer to the RGBA8 buffer.
iwWidth in pixels of the RGBA8 buffer.
ihHeight in pixels of the RGBA8 buffer.
strideBytes per line of pixels of the RGBA8 buffer.

◆ bytes_per_line()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr size_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::bytes_per_line ( )
inlinestaticnodiscardconstexpr

Bytes per line in the image data. Also called stride.

Returns
Bytes per line in the image data.

◆ circle()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::circle ( int32_t cx,
int32_t cy,
int32_t r )
inlineconstexpr

Create a circle shape for fluent method chaining.

Parameters
cxCenter X-coordinate in pixels.
cyCenter Y-coordinate in pixels.
rRadius of the circle in pixels.
Returns
A circle shape object that supports .fill() and .stroke() methods.

◆ circle_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::circle_aa ( int32_t cx,
int32_t cy,
int32_t r )
inlineconstexpr

Create an antialiased circle shape for fluent method chaining. Only format_8bit targets are supported.

Parameters
cxCenter X-coordinate in pixels.
cyCenter Y-coordinate in pixels.
rRadius of the circle in pixels.
Returns
A circle_aa shape object that supports .fill() and .stroke() methods.

◆ clone()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
image< T, W, H, GRAYSCALE > constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::clone ( ) const
inlinenodiscardconstexpr

Returns a clone of this image. Data is copied.

Returns
Cloned image instance.

◆ convert()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<device_format dst_format, typename F>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::convert ( F && uint8_out)
inlineconstexpr

Convert the current instance into a byte stream formatted for embedded displays.

Template Parameters
dst_formatThe desired data format.
Parameters
uint8_outA lambda function which consumes the data stream one byte at a time.

◆ copy() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::copy ( const image< T, W, H, GRAYSCALE > & src)
inlineconstexpr

Copy source image into this instance. No compositing occurs, replaces current content.

Parameters
srcSource image.

◆ copy() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<size_t BYTE_SIZE>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::copy ( const uint8_t * src)
inlineconstexpr

Copy raw source data into this instance. No compositing occurs.

Template Parameters
BYTE_SIZEAmount data in the source data. Typically a sizeof() of an array. Must match image::size()
Parameters
srcSource data.

◆ data_ref()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
std::array< uint8_t, T< W, H, GRAYSCALE, USE_SPAN >::image_size > & constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::data_ref ( )
inlinenodiscardconstexpr

Get a reference to the underlying raw data of the image.

Returns
Reference to the data array which contains the raw image data.

◆ draw_line() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_line ( const struct draw_line & d)
inlineconstexpr

Draw a line with the specified color and thickness. Example:

image.draw_line({.x0=0, .y0=0, .x1=200, .y1=100, .col=color::WHITE, .sw=2});
Parameters
ddraw_line initializer struct

◆ draw_line() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_line ( int32_t x0,
int32_t y0,
int32_t x1,
int32_t y1,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Draw a line with the specified color and thickness. Example:

image.draw_line(0, 0, 200, 100, constixel::color::WHITE, 2);
Parameters
x0Starting X-coordinate in pixels.
y0Starting Y-coordinate in pixels.
x1Ending X-coordinate in pixels.
y1Ending Y-coordinate in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ draw_line_aa() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_line_aa ( const struct draw_line & d)
inlineconstexpr

Draw a 1-pixel wide antialiased line with the specified color. Only format_8bit targets are supported. Example:

image.draw_line_aa({.x0=0, .y0=0, .x1=200, .y1=100, .col=color::WHITE, .sw=2.5f});
Parameters
ddraw_line initializer struct

◆ draw_line_aa() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_line_aa ( int32_t x0,
int32_t y0,
int32_t x1,
int32_t y1,
uint8_t col,
float stroke_width = 1.0f )
inlineconstexpr

Draw an antialiased line with variable stroke width. Only format_8bit targets are supported. Example:

image.draw_line_aa(0, 0, 200, 100, constixel::color::WHITE, 3.0f);
Parameters
x0Starting X-coordinate in pixels.
y0Starting Y-coordinate in pixels.
x1Ending X-coordinate in pixels.
y1Ending Y-coordinate in pixels.
colColor palette index to use.
stroke_widthWidth of the line in pixels (can be fractional).

◆ draw_string_aa() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_aa ( const struct draw_string & d,
size_t character_count = std::numeric_limits<size_t>::max(),
size_t * character_actual = nullptr )
inlineconstexpr

Draw antialiased text at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use:

#include "some_font_aa.h"
...
image.draw_string_aa<constixel::some_font_aa>({.x=0, .y=0, .str="MyText", .col=constixel::color::WHITE});
...
Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
ddraw_string initializer struct.
character_countHow many utf32 characters in the string should be drawn.
character_actualHow many utf32 characters in the string were drawn.
Returns
Returns the new caret X-coordinate position. Pass this value to the next draw_string call to get continious text.

◆ draw_string_aa() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_aa ( int32_t x,
int32_t y,
const char * str,
uint8_t col,
size_t character_count = std::numeric_limits<size_t>::max(),
size_t * character_actual = nullptr )
inlineconstexpr

Draw antialiased text at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use:

#include "some_font_aa.h"
...
image.draw_string_aa<constixel::some_font_aa>(0, 0, "MyText", constixel::color::WHITE);
...
Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
strUTF-8 string.
colColor palette index to use.
character_countHow many utf32 characters in the string should be drawn.
character_actualHow many utf32 characters in the string were drawn.
Returns
Returns the new caret X-coordinate position. Pass this value to the next draw_string call to get continious text.

◆ draw_string_centered_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_centered_aa ( int32_t x,
int32_t y,
const char * str,
uint8_t col )
inlineconstexpr

Draw antialiased text centered at the specified coordinate. The template parameter selects which antialiased font to use. Only format_8bit targets are supported. Typical use.

Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
xCenter/Starting X-coordinate in pixels.
yCenter/Starting Y-coordinate in pixels.
strUTF-8 string.
colColor palette index to use.

◆ draw_string_centered_mono()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_centered_mono ( int32_t x,
int32_t y,
const char * str,
uint8_t col )
inlineconstexpr

Draw text centered at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.

Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
xCenter/Starting X-coordinate in pixels.
yCenter/Starting Y-coordinate in pixels.
strUTF-8 string.
colColor palette index to use.

◆ draw_string_mono() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_mono ( const struct draw_string & d,
size_t character_count = std::numeric_limits<size_t>::max(),
size_t * character_actual = nullptr )
inlineconstexpr

Draw text at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.

#include "some_font_mono.h"
...
image.draw_string_mono<constixel::some_font_mono>({.x=0, .y=0, .str="MyText", .col=constixel::color::WHITE});
...
Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Defaults to text_rotation::DEGREE_0. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
ddraw_string initializer struct.
character_countHow many utf32 characters in the string should be drawn.
character_actualHow many utf32 characters in the string were drawn.
Returns
Returns the new caret X-coordinate position. Pass this value to the next draw_string call to get continious text.

◆ draw_string_mono() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::draw_string_mono ( int32_t x,
int32_t y,
const char * str,
uint8_t col,
size_t character_count = std::numeric_limits<size_t>::max(),
size_t * character_actual = nullptr )
inlineconstexpr

Draw text at the specified coordinate. The template parameter selects which mono font to use. Only format_8bit targets are supported.

#include "some_font_mono.h"
...
image.draw_string_mono<constixel::some_font_mono>(0, 0, "MyText", constixel::color::WHITE);
...
Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available. Default to false.
ROTATIONRotation around the x/y coordinate. Defaults to text_rotation::DEGREE_0. Can be text_rotation::DEGREE_0, text_rotation::DEGREE_90, text_rotation::DEGREE_180 or text_rotation::DEGREE_270
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
strUTF-8 string.
colColor palette index to use.
character_countHow many utf32 characters in the string should be drawn.
character_actualHow many utf32 characters in the string were drawn.
Returns
Returns the new caret X-coordinate position. Pass this value to the next draw_string call to get continious text.

◆ fill_circle() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_circle ( const struct draw_circle & d)
inlineconstexpr

Fill a circle with the specified radius and color. Example:

image.fill_circle({.cx=64, .cy=64, .r=32, .col=constixel::color::WHITE});
Parameters
ddraw_circle initializer struct

◆ fill_circle() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_circle ( int32_t cx,
int32_t cy,
int32_t radius,
uint8_t col )
inlineconstexpr

Fill a circle with the specified radius and color. Example:

image.fill_circle(64, 64, 32, constixel::color::WHITE);
Parameters
cxCenter X-coordinate of the circle in pixels.
cyCenter Y-coordinate of the circle in pixels.
radiusradius of the circle in pixels.
colColor palette index to use.

◆ fill_circle_aa() [1/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_circle_aa ( const struct draw_circle & d)
inlineconstexpr

Fill a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:

image.fill_circle_aa({.cx=64, .cy=64, .r=32, .col=constixel::color::WHITE});
Parameters
ddraw_circle initializer struct

◆ fill_circle_aa() [2/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_circle_aa ( int32_t cx,
int32_t cy,
int32_t radius,
const shader_func & shader ) -> void
inlineconstexpr

Fill a circle using antialiasing with a shader function that generates colors per pixel.

// Radial gradient circle
image.fill_circle_aa(100, 100, 50, [](float u, float v, float au, float av) -> std::array<float, 4> {
float dist = std::sqrt((u - 0.5f) * (u - 0.5f) + (v - 0.5f) * (v - 0.5f)) * 2.0f;
float intensity = 1.0f - std::clamp(dist, 0.0f, 1.0f);
return {intensity, intensity * 0.8f, 1.0f, 1.0f}; // R, G, B, A
});
Parameters
cxCenter X-coordinate of the circle in pixels.
cyCenter Y-coordinate of the circle in pixels.
radiusRadius of the circle in pixels.
shaderLambda function taking (u, v, x, y) normalized coordinates and returning RGBA color as std::array<float, 4>

◆ fill_circle_aa() [3/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_circle_aa ( int32_t cx,
int32_t cy,
int32_t radius,
uint8_t col )
inlineconstexpr

Fill a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:

image.fill_circle_aa(64, 64, 32, constixel::color::WHITE);
Parameters
cxCenter X-coordinate of the circle in pixels.
cyCenter Y-coordinate of the circle in pixels.
radiusRadius of the circle in pixels.
colColor palette index to use.

◆ fill_rect() [1/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_rect ( const struct draw_rect & d)
inlineconstexpr

Fill a rectangle with the specified color. Example:

image.fill_rect({.x=0, .y=0, .w=320, .h=240, .col=constixel::color::WHITE});
Parameters
ddraw_rect initializer struct

◆ fill_rect() [2/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
const shader_func & shader ) -> void
inlineconstexpr

Fill a rectangle with a shader function that generates colors per pixel.

// Linear gradient from red to blue
image.fill_rect(0, 0, 320, 240, [](float u, float v, float au, float av) -> std::array<float, 4> {
return {1.0f - u, 0.0f, u, 1.0f}; // R, G, B, A
});
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
shaderLambda function taking (u, v, x, y) normalized coordinates and returning RGBA color as std::array<float, 4>

◆ fill_rect() [3/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
uint8_t col )
inlineconstexpr

Fill a rectangle with the specified color. Example:

image.fill_rect(0, 0, 320, 240, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
colColor palette index to use.

◆ fill_round_rect() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_round_rect ( const struct draw_round_rect & d)
inlineconstexpr

Fill a rounded rectangle with the specified color. Example:

image.fill_round_rect({.x=0, .y=0, .w=200, .h=100, .r=15, .col=constixel::color::WHITE});
Parameters
ddraw_round_rect initializer struct

◆ fill_round_rect() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_round_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius,
uint8_t col )
inlineconstexpr

Fill a rounded rectangle with the specified color. Example:

image.fill_round_rect(0, 0, 200, 100, 15, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
colColor palette index to use.

◆ fill_round_rect_aa() [1/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_round_rect_aa ( const struct draw_round_rect & d)
inlineconstexpr

Fill a rounded rectangle using antialiasing with the specified color. Only format_8bit targets are supported.

image.fill_round_rect_aa({.x=0, .y=0, .w=200, .h=100, .r=15, .col=constixel::color::WHITE, .sw=8});
Parameters
ddraw_round_rect initializer struct

◆ fill_round_rect_aa() [2/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename shader_func>
requires std::is_invocable_r_v<std::array<float, 4>, shader_func, float, float, int32_t, int32_t>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_round_rect_aa ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius,
const shader_func & shader ) -> void
inlineconstexpr

Fill a rounded rectangle using antialiasing with a shader function that generates colors per pixel.

// Gradient rounded rectangle
image.fill_round_rect_aa(10, 10, 200, 100, 15, [](float u, float v, float au, float av) -> std::array<float, 4> {
return {u, v, 1.0f - u, 1.0f}; // Corner-to-corner gradient
});
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
shaderLambda function taking (u, v, x, y) normalized coordinates and returning RGBA color as std::array<float, 4>

◆ fill_round_rect_aa() [3/3]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::fill_round_rect_aa ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius,
uint8_t col )
inlineconstexpr

Fill a rounded rectangle using antialiasing with the specified color. Only format_8bit targets are supported. Example:

image.fill_round_rect_aa(0, 0, 200, 100, 15, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle.
hHeight of the rectangle.
radiusRadius of the rounded corners.
colColor palette index to use.

◆ get_nearest_color()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
uint8_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::get_nearest_color ( uint8_t r,
uint8_t g,
uint8_t b ) const
inlinenodiscardconstexpr

Return closest match in the color palette based on the supplied red, green and blue values.

Parameters
rRed value (0-255)
gGreen value (0-255)
bBlue value (0-255)
Returns
The closest matching color palette index.

◆ grayscale()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr bool constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::grayscale ( )
inlinestaticnodiscardconstexpr

Boolean indicating that the palette is grayscale instead of color.

Returns
If true, the palette is grayscale. If false a colored palette is used.

◆ height()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::height ( )
inlinestaticnodiscardconstexpr

Height in pixels of the image.

Returns
Height in pixels of the image.

◆ line()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::line ( int32_t x0,
int32_t y0,
int32_t x1,
int32_t y1 )
inlineconstexpr

Create a line shape for fluent method chaining.

Parameters
x0Starting X-coordinate in pixels.
y0Starting Y-coordinate in pixels.
x1Ending X-coordinate in pixels.
y1Ending Y-coordinate in pixels.
Returns
A line shape object that supports .stroke() method.

◆ line_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::line_aa ( int32_t x0,
int32_t y0,
int32_t x1,
int32_t y1 )
inlineconstexpr

Create an antialiased line shape for fluent method chaining. Only format_8bit targets are supported.

Parameters
x0Starting X-coordinate in pixels.
y0Starting Y-coordinate in pixels.
x1Ending X-coordinate in pixels.
y1Ending Y-coordinate in pixels.
Returns
A line_aa shape object that supports .stroke() method.

◆ plot() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::plot ( const struct plot & p)
inlineconstexpr

Plot a single pixel at the specified coordinates using the supplied color.

Parameters
pplot initializer struct

◆ plot() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::plot ( int32_t x,
int32_t y,
uint8_t col )
inlineconstexpr

Plot a single pixel at the specified coordinates using the supplied color.

Parameters
xX-coordinate in pixels.
yY-coordinate in pixels.
colColor palette index to use.

◆ png()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename F>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::png ( F && char_out) const
inlineconstexpr

Convert the current instance into a png image. Typically an implementation looks like this:

auto some_container;
image.png([=](char ch) mutable {
some_container.push_back(ch);
});
Parameters
char_outA lambda function which consumes the png image data one byte at a time.

◆ point()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::point ( int32_t x,
int32_t y )
inlineconstexpr

Create a point shape for fluent method chaining.

Parameters
xX-coordinate in pixels.
yY-coordinate in pixels.
Returns
A point shape object that supports .plot() method.

◆ rect()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h )
inlineconstexpr

Fluent shape API methods for method chaining These provide a more expressive way to create shapes compared to struct-based calls.

Example usage:

image.rect(10, 10, 50, 30).fill(constixel::color::RED).stroke(constixel::color::BLACK, 2);
image.circle(100, 100, 20).fill(constixel::color::BLUE);
image.line(0, 0, 100, 100).stroke(constixel::color::WHITE, 3);

Create a rectangle shape for fluent method chaining.

Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
Returns
A rect shape object that supports .fill() and .stroke() methods.

◆ RGBA_uint32()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::RGBA_uint32 ( std::array< uint32_t, W *H > & dst) const
inlineconstexpr

Convert this instance to an equivalent RGBA8 data array.

Parameters
dstRGBA8 array made of image::width() * img::height() * uint32_t values.

◆ RGBA_uint8()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::RGBA_uint8 ( std::array< uint8_t, W *H *4 > & dst) const
inlineconstexpr

Convert this instance to an equivalent RGBA8 data array.

Parameters
dstRGBA8 array made of image::width() * img::height() * 4 * uint8_t values.

◆ round_rect()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::round_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius )
inlineconstexpr

Create a rounded rectangle shape for fluent method chaining.

Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
Returns
A round_rect shape object that supports .fill() and .stroke() methods.

◆ round_rect_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::round_rect_aa ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius )
inlineconstexpr

Create an antialiased rounded rectangle shape for fluent method chaining. Only format_8bit targets are supported.

Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
Returns
A round_rect_aa shape object that supports .fill() and .stroke() methods.

◆ sixel() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<size_t S = 1, typename F>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::sixel ( F && char_out) const
inlineconstexpr

Convert the current instance into a sixel stream. Typically an implementation looks like this:

auto some_container;
image.sixel([=](char ch) mutable {
some_container.push_back(ch);
});
Template Parameters
Sscale of sixel output.
Parameters
char_outA lambda function which consumes the sixel stream data one byte at a time.

◆ sixel() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<size_t S = 1, typename F>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::sixel ( F && char_out,
const rect< int32_t > & rect ) const
inlineconstexpr

Convert the current instance into a sixel stream. Typically an implementation looks like this:

auto some_container;
image.sixel({.x=0,.y=0,.w=100,.h=100},[=](char ch) mutable {
some_container.push_back(ch);
});
Template Parameters
Sscale of sixel output.
Parameters
char_outA lambda function which consumes the sixel stream data one byte at a time
rectClipping rectangle; to only show a portion of the image.

◆ sixel_to_cout()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<size_t S = 1>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::sixel_to_cout ( ) const
inline

Convert the current instance into a sixel stream and output it to std::cout.

Template Parameters
Sscale of sixel output.

◆ size()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr size_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::size ( )
inlinestaticnodiscardconstexpr

Size in bytes of the image data. This does not include the image instance size.

Returns
Size in bytes of the image data.

◆ string_width()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false>
int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::string_width ( const char * str,
size_t character_count = std::numeric_limits<size_t>::max(),
size_t * character_actual = nullptr )
inlinenodiscardconstexpr

Return the width of a string using the specified font in the template parameter. Typical use:

#include "some_font_aa.h"
...
int32_t width = image.string_width<constixel::some_font_aa>();
...
static constexpr int32_t width()
Width in pixels of the image.
Definition constixel.hpp:3572
Template Parameters
FONTThe font struct name.
KERNINGBoolean, use kerning information if available.
Parameters
strUTF-8 string.
character_countHow many utf32 characters in the string should be measured.
character_actualHow many utf32 characters in the string were measured.
Returns
Width of the string in pixels.

◆ stroke_circle() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_circle ( const struct draw_circle & d)
inlineconstexpr

Stroke a circle with the specified radius and color. Example:

image.stroke_circle({.cx=64, .cy=64, .r=32, .col=constixel::color::WHITE, .sw=2});
Parameters
ddraw_circle initializer struct

◆ stroke_circle() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_circle ( int32_t cx,
int32_t cy,
int32_t radius,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Stroke a circle with the specified radius and color. Example:

image.stroke_circle(64, 64, 32, 4, constixel::color::WHITE);
Parameters
cxCenter X-coordinate of the circle in pixels.
cyCenter Y-coordinate of the circle in pixels.
radiusradius of the circle in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ stroke_circle_aa() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_circle_aa ( const struct draw_circle & d)
inlineconstexpr

Stroke a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:

image.stroke_circle_aa({.cx=64, .cy=64, .r=32, .col=constixel::color::WHITE, .sw=2});
Parameters
ddraw_circle initializer struct

◆ stroke_circle_aa() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_circle_aa ( int32_t cx,
int32_t cy,
int32_t radius,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Stroke a circle using antialiasing with the specified radius and color. Only format_8bit targets are supported. Example:

image.stroke_circle_aa(64, 64, 32, constixel::color::WHITE, 2);
Parameters
cxCenter X-coordinate of the circle in pixels.
cyCenter Y-coordinate of the circle in pixels.
radiusradius of the circle in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ stroke_rect() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_rect ( const struct draw_rect & d)
inlineconstexpr

Draw a stroked rectangle with the specified color and stroke width. Example:

image.stroke_rect({.x=0, .y=0, .w=320, .h=240, .col=constixel::color::WHITE, .sw=2});
Parameters
ddraw_rect initializer struct

◆ stroke_rect() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Draw a stroked rectangle with the specified color and stroke width. Example:

image.stroke_rect(0, 0, 320, 240, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ stroke_round_rect() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_round_rect ( const struct draw_round_rect & d)
inlineconstexpr

Stroke a rounded rectangle with the specified color. Example:

image.stroke_round_rect({.x=0, .y=0, .w=200, .h=100, .r=15, .col=constixel::color::WHITE, .sw=8});
Parameters
ddraw_round_rect initializer struct

◆ stroke_round_rect() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_round_rect ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Stroke a rounded rectangle with the specified color. Example:

image.stroke_round_rect(0, 0, 200, 100, 15, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ stroke_round_rect_aa() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_round_rect_aa ( const struct draw_round_rect & d)
inlineconstexpr

Stroke a rounded rectangle using antialiasing with the specified color. Example:

image.stroke_round_rect_aa({.x=0, .y=0, .w=200, .h=100, .r=15, .col=constixel::color::WHITE, .sw=8});
Parameters
ddraw_round_rect initializer struct

◆ stroke_round_rect_aa() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::stroke_round_rect_aa ( int32_t x,
int32_t y,
int32_t w,
int32_t h,
int32_t radius,
uint8_t col,
int32_t stroke_width = 1 )
inlineconstexpr

Stroke a rounded rectangle using antialiasing with the specified color. Example:

image.stroke_round_rect_aa(0, 0, 200, 100, 15, constixel::color::WHITE);
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
wWidth of the rectangle in pixels.
hHeight of the rectangle in pixels.
radiusRadius of the rounded corners in pixels.
colColor palette index to use.
stroke_widthWidth of the stroke in pixels.

◆ text_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::text_aa ( int32_t x,
int32_t y,
const char * str )
inlineconstexpr

Create a text shape for fluent antialiased string drawing with method chaining. Only format_8bit targets are supported.

Template Parameters
FONTThe font type to use for rendering.
KERNINGEnable kerning if true (default: false).
ROTATIONText rotation (default: DEGREE_0).
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
strThe string to draw.
Returns
A text_aa shape object that supports .color() and .draw() methods.

Example usage:

img.text_aa<constixel::ibmplexmono_regular_12_aa>(10, 20, "Hello").color(constixel::color::WHITE);

◆ text_centered_aa()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::text_centered_aa ( int32_t x,
int32_t y,
const char * str )
inlineconstexpr

Create a text shape for fluent centered antialiased string drawing with method chaining. Only format_8bit targets are supported.

Template Parameters
FONTThe font type to use for rendering.
KERNINGEnable kerning if true (default: false).
ROTATIONText rotation (default: DEGREE_0).
Parameters
xCenter X-coordinate in pixels.
yCenter Y-coordinate in pixels.
strThe string to draw.
Returns
A text_centered_aa shape object that supports .color() method.

Example usage:

img.text_centered_aa<constixel::ibmplexmono_regular_12_aa>(100, 50, "Centered").color(constixel::color::WHITE);

◆ text_centered_mono()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::text_centered_mono ( int32_t x,
int32_t y,
const char * str )
inlineconstexpr

Create a text shape for fluent centered monospace string drawing with method chaining.

Template Parameters
FONTThe font type to use for rendering.
KERNINGEnable kerning if true (default: false).
ROTATIONText rotation (default: DEGREE_0).
Parameters
xCenter X-coordinate in pixels.
yCenter Y-coordinate in pixels.
strThe string to draw.
Returns
A text_centered_mono shape object that supports .color() method.

Example usage:

img.text_centered_mono<constixel::ibmplexmono_regular_12_mono>(100, 50,
"Centered").color(constixel::color::WHITE);

◆ text_mono()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<typename FONT, bool KERNING = false, text_rotation ROTATION = DEGREE_0>
auto constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::text_mono ( int32_t x,
int32_t y,
const char * str )
inlineconstexpr

Create a text shape for fluent monospace string drawing with method chaining.

Template Parameters
FONTThe font type to use for rendering.
KERNINGEnable kerning if true (default: false).
ROTATIONText rotation (default: DEGREE_0).
Parameters
xStarting X-coordinate in pixels.
yStarting Y-coordinate in pixels.
strThe string to draw.
Returns
A text_mono shape object that supports .color() and .draw() methods.

Example usage:

img.text_mono<constixel::ibmplexmono_regular_12_mono>(10, 20, "Hello").color(constixel::color::WHITE);

◆ transpose() [1/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<bool FLIP_H = false, bool FLIP_V = false>
image< T, H, W, GRAYSCALE > constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::transpose ( ) const
inlineconstexpr

Return a transposed version of this image.

Template Parameters
FLIP_HFlip image horizontally
FLIP_VFlip image vertically

◆ transpose() [2/2]

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
template<bool FLIP_H = false, bool FLIP_V = false>
void constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::transpose ( image< T, H, W, GRAYSCALE > & dst) const
inlineconstexpr

Transpose this image into another.

Template Parameters
FLIP_HFlip image horizontally
FLIP_VFlip image vertically

◆ width()

template<template< size_t, size_t, bool, bool > class T, size_t W, size_t H, bool GRAYSCALE = false, bool USE_SPAN = false>
static constexpr int32_t constixel::image< T, W, H, GRAYSCALE, USE_SPAN >::width ( )
inlinestaticnodiscardconstexpr

Width in pixels of the image.

Returns
Width in pixels of the image.

The documentation for this class was generated from the following file: