TGX 1.0.0
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
Loading...
Searching...
No Matches
tgx::Image< color_t > Class Template Reference

Image class [MAIN CLASS FOR THE 2D API]. More...

#include <Image.h>

Public Member Functions

Creation of image and sub-images.

If the memory buffer is not supplied at creation, the image is marked as invalid until a buffer is set.

Remarks
  1. The image object does not manage the buffer memory: memory allocation/deallocation is the user's respnsability.
  2. The image class is lightweight: creating image and sub-image is very fast and requires no additional memory.
 Image ()
 Default constructor. More...
 
template<typename T >
 Image (T *buffer, int lx, int ly, int stride=DEFAULT_STRIDE)
 Constructor. More...
 
template<typename T >
 Image (T *buffer, iVec2 dim, int stride=DEFAULT_STRIDE)
 Constructor. More...
 
 Image (const Image< color_t > &im, iBox2 subbox)
 Constructor. More...
 
 Image (const Image< color_t > &im)=default
 Default copy constructor. More...
 
Imageoperator= (const Image< color_t > &im)=default
 Default assignement operator. More...
 
template<typename T >
void set (T *buffer, int lx, int ly, int stride=DEFAULT_STRIDE)
 Set/update the image parameters. More...
 
template<typename T >
void set (T *buffer, iVec2 dim, int stride=DEFAULT_STRIDE)
 Set/update the image parameters. More...
 
void crop (const iBox2 &subbox)
 Crop the image. More...
 
Image< color_t > getCrop (const iBox2 &subbox) const
 Return a sub-image of this image (sharing the same pixel buffer). More...
 
Image< color_t > operator() (const iBox2 &B) const
 Return a sub-image of this image (sharing the same pixel buffer). More...
 
Image< color_t > operator() (int min_x, int max_x, int min_y, int max_y) const
 Return a sub-image of this image (sharing the same pixel buffer). More...
 
Image attributes.

Query the state (dimension, buffer...) of the image.


TGX_INLINE bool isValid () const
 Query if the image is valid. More...
 
void setInvalid ()
 Set the image as invalid. More...
 
TGX_INLINE int width () const
 Return the image width. More...
 
TGX_INLINE int lx () const
 Return the image width. More...
 
TGX_INLINE int height () const
 Return the image height. More...
 
TGX_INLINE int ly () const
 Return the image height. More...
 
TGX_INLINE int stride () const
 Return the image stride. More...
 
TGX_INLINE iVec2 dim () const
 Return the image dimensions as an iVec2. More...
 
TGX_INLINE iBox2 imageBox () const
 Return the image dimension as a box. More...
 
TGX_INLINE const color_t * data () const
 Return a pointer to the pixel buffer. More...
 
TGX_INLINE color_t * data ()
 Return a pointer to the pixel buffer. More...
 
Direct pixel access.

Methods to read/write pixels directly on the image buffer.

template<bool CHECKRANGE = true>
TGX_INLINE void drawPixel (iVec2 pos, color_t color)
 Set a pixel at a given position. More...
 
template<bool CHECKRANGE = true>
TGX_INLINE void drawPixelf (fVec2 pos, color_t color)
 Set a pixel at a given position (floating point coord). More...
 
template<bool CHECKRANGE = true>
TGX_INLINE void drawPixel (iVec2 pos, color_t color, float opacity)
 Blend a pixel with the current pixel color. More...
 
template<bool CHECKRANGE = true>
TGX_INLINE void drawPixelf (fVec2 pos, color_t color, float opacity)
 Blend a pixel with the current pixel color (floating point coord). More...
 
template<bool CHECKRANGE = true>
TGX_INLINE color_t readPixel (iVec2 pos, color_t outside_color=color_t()) const
 Return the color of a pixel at a given position. More...
 
template<bool CHECKRANGE = true>
TGX_INLINE color_t readPixelf (fVec2 pos, color_t outside_color=color_t()) const
 Return the color of a pixel at a given position (floating point coord). More...
 
TGX_INLINE const color_t & operator() (iVec2 pos) const
 Get a reference to a pixel (no range check!) More...
 
TGX_INLINE color_t & operator() (iVec2 pos)
 Get a reference to a pixel (no range check!) More...
 
TGX_INLINE const color_t & operator() (int x, int y) const
 Get a reference to a pixel (no range check!) More...
 
TGX_INLINE color_t & operator() (int x, int y)
 Get a reference to a pixel (no range check!) More...
 
template<typename ITERFUN >
void iterate (ITERFUN cb_fun)
 Iterate over all the pixels of the image. More...
 
template<typename ITERFUN >
void iterate (ITERFUN cb_fun) const
 Iterate over all the pixels of the image. More...
 
template<typename ITERFUN >
void iterate (ITERFUN cb_fun, tgx::iBox2 B)
 Iterate over the pixel of the image inside a given region. More...
 
template<typename ITERFUN >
void iterate (ITERFUN cb_fun, tgx::iBox2 B) const
 Iterate over the pixel of the image inside a given region. More...
 
Image manipulation.

Methods for blitting, converting, resizing and rotating images.

void blit (const Image< color_t > &sprite, iVec2 upperleftpos, float opacity=TGX_DEFAULT_NO_BLENDING)
 Blit/blend a sprite over this image at a given position. More...
 
template<typename color_t_src , typename BLEND_OPERATOR >
void blit (const Image< color_t_src > &sprite, iVec2 upperleftpos, const BLEND_OPERATOR &blend_op)
 Blend a sprite at a given position on the image using a custom blending operator. More...
 
void blitRotated (const Image< color_t > &sprite, iVec2 upperleftpos, int angle, float opacity=TGX_DEFAULT_NO_BLENDING)
 Blit/blend a rotated sprite over this image at a given position. More...
 
template<typename color_t_src , typename BLEND_OPERATOR >
void blitRotated (const Image< color_t_src > &sprite, iVec2 upperleftpos, int angle, const BLEND_OPERATOR &blend_op)
 Blend a rotated sprite over this image at a given position using a custom blending operator. More...
 
void blitMasked (const Image< color_t > &sprite, color_t transparent_color, iVec2 upperleftpos, float opacity=1.0f)
 Blend a sprite at a given position on this image with a given mask. More...
 
void blitBackward (Image< color_t > &dst_sprite, iVec2 upperleftpos) const
 Reverse blitting. More...
 
template<typename color_t_src , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void blitScaledRotated (const Image< color_t_src > src_im, fVec2 anchor_src, fVec2 anchor_dst, float scale=1.0f, float angle_degrees=0.0f, float opacity=TGX_DEFAULT_NO_BLENDING)
 Blit/blend a sprite onto this image after rescaling and rotation. More...
 
template<typename color_t_src , typename BLEND_OPERATOR , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void blitScaledRotated (const Image< color_t_src > &src_im, fVec2 anchor_src, fVec2 anchor_dst, float scale, float angle_degrees, const BLEND_OPERATOR &blend_op)
 Blend a sprite onto this image after rescaling and rotation using a custom blending operator. More...
 
template<typename color_t_src , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void blitScaledRotatedMasked (const Image< color_t_src > &src_im, color_t_src transparent_color, fVec2 anchor_src, fVec2 anchor_dst, float scale, float angle_degrees, float opacity=1.0f)
 Blend a sprite onto this image after rescaling and rotation and use a given color which is treated as fully transparent. More...
 
template<typename src_color_t >
void copyFrom (const Image< src_color_t > &src_im, float opacity=TGX_DEFAULT_NO_BLENDING)
 Copy (or blend) the src image onto the destination image with resizing and color conversion. More...
 
template<typename src_color_t , typename BLEND_OPERATOR >
void copyFrom (const Image< src_color_t > &src_im, const BLEND_OPERATOR &blend_op)
 Blend the src image onto the destination image with resizing and color conversion. More...
 
Image< color_t > copyReduceHalf (const Image< color_t > &src_image)
 Copy the source image pixels into this image, reducing it by half in the process. More...
 
Image< color_t > reduceHalf ()
 Reduce this image by half. More...
 
template<typename color_dst >
Image< color_dst > convert ()
 Convert this image to another type. More...
 
Drawing primitives: filling a region.

Method for filling the whole (or just a region of the) image with a given color.


void fillScreen (color_t color)
 Fill the whole image with a single color. More...
 
void clear (color_t color)
 Fill the whole image with a single color. More...
 
void fillScreenVGradient (color_t top_color, color_t bottom_color)
 Fill the whole image with a vertical color gradient between two colors. More...
 
void fillScreenHGradient (color_t left_color, color_t right_color)
 Fill the whole screen with an horizontal color gradient between two colors. More...
 
template<int STACK_SIZE = 1024>
int fill (iVec2 start_pos, color_t new_color)
 'Flood fill' a 4-connected region of the image. More...
 
template<int STACK_SIZE = 1024>
int fill (iVec2 start_pos, color_t border_color, color_t new_color)
 'Flood fill' a 4-connected region of the image. More...
 
Drawing primitives: lines.

FAST/REGULAR METHODS

void drawFastVLine (iVec2 pos, int h, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw an vertical segment of h pixels starting at pos. More...
 
void drawFastHLine (iVec2 pos, int w, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw an horizontal segment of w pixels starting at pos. More...
 
void drawLine (iVec2 P1, iVec2 P2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a line segment between two points (uses Bresenham's algorithm). More...
 
void drawSegment (iVec2 P1, bool drawP1, iVec2 P2, bool drawP2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a line segment between two points (using Bresenham's algorithm). More...
 
Drawing primitives: lines (AA).

HIGH QUALITY DRAWING

void drawLineAA (fVec2 P1, fVec2 P2, color_t color, float opacity=1.0f)
 Draw a line segment between two points [High quality]. More...
 
void drawThickLineAA (fVec2 P1, fVec2 P2, float line_width, EndPath end_P1, EndPath end_P2, color_t color, float opacity=1.0f)
 Draw a thick line segment between two points [High quality]. More...
 
void drawWedgeLineAA (fVec2 P1, fVec2 P2, float line_width_P1, EndPath end_P1, float line_width_P2, EndPath end_P2, color_t color, float opacity=1.0f)
 Draw a from P1 to P2 with with respective wideness line_width_P1 and line_width_P2 at both ends [High quality]. More...
 
Drawing primitives: rectangles.

FAST/REGULAR METHODS

void drawRect (const iBox2 &B, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a rectangle. More...
 
void drawThickRect (const iBox2 &B, int thickness, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a rectangle with a thick outline. More...
 
void fillRect (const iBox2 &B, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled rectangle. More...
 
void fillThickRect (const iBox2 &B, int thickness, color_t color_interior, color_t color_border, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled rectangle with a thick border of a possibly different color. More...
 
void fillRectHGradient (iBox2 B, color_t color_left, color_t color_right, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a rectangle filled with an horizontal gradient of colors. More...
 
void fillRectVGradient (iBox2 B, color_t color_top, color_t color_bottom, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a rectangle filled with a vertical gradient of colors. More...
 
Drawing primitives: rectangles. (AA)

HIGH QUALITY DRAWING

Remarks
  1. Sub-pixel precision and anti-aliasing is usually not desirable when drawing rectangle. The method below should not be needed in usual circonstance (but may be useful for creating very smooth animations).
  2. Recall that pixel centers are at integer values (and the full image range is [-0.5, lx - 0.5] x [-0.5, lx-0.5]), therefore, giving a fVec2 box with integer values to the method below will create aliasing along the edges of the rectangle...
void drawThickRectAA (const fBox2 &B, float thickness, color_t color, float opacity=1.0f)
 Draw a filled rectangle with a thick border [High quality]. More...
 
void fillRectAA (const fBox2 &B, color_t color, float opacity=1.0f)
 Draw a filled rectangle [High quality]. More...
 
void fillThickRectAA (const fBox2 &B, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled rectangle with a thick border of a different color [High quality]. More...
 
Drawing primitives: rounded rectangles.

FAST/REGULAR METHODS

void drawRoundRect (const iBox2 &B, int corner_radius, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a rounded rectangle in box B with radius corner_radius. More...
 
void fillRoundRect (const iBox2 &B, int corner_radius, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled rounded rectangle in box B with radius corner_radius. More...
 
Drawing primitives: rounded rectangles (AA).

HIGH QUALITY DRAWING

void drawRoundRectAA (const fBox2 &B, float corner_radius, color_t color, float opacity=1.0f)
 Draw a rounded rectangle [High quality]. More...
 
void drawThickRoundRectAA (const fBox2 &B, float corner_radius, float thickness, color_t color, float opacity=1.0f)
 Draw a rounded rectangle with a thick border [High quality]. More...
 
void fillRoundRectAA (const fBox2 &B, float corner_radius, color_t color, float opacity=1.0f)
 Draw a filled rounded rectangle [High quality]. More...
 
void fillThickRoundRectAA (const fBox2 &B, float corner_radius, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled rounded rectangle with a thick border of another color [High quality]. More...
 
Drawing primitives: triangles.

FAST/REGULAR METHODS

void drawTriangle (const iVec2 &P1, const iVec2 &P2, const iVec2 &P3, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a triangle. More...
 
void fillTriangle (const iVec2 &P1, const iVec2 &P2, const iVec2 &P3, color_t interior_color, color_t outline_color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled triangle with different colors for the outline and the interior. More...
 
Drawing primitives: triangles (AA).

HIGH QUALITY DRAWING

void drawTriangleAA (fVec2 P1, fVec2 P2, fVec2 P3, color_t color, float opacity=1.0f)
 Draw a triangle [High quality]. More...
 
void drawThickTriangleAA (fVec2 P1, fVec2 P2, fVec2 P3, float thickness, color_t color, float opacity=1.0f)
 Draw a triangle with a thick border [High quality]. More...
 
void fillTriangleAA (fVec2 P1, fVec2 P2, fVec2 P3, color_t color, float opacity=1.0f)
 Draw a filled triangle [High quality]. More...
 
void fillThickTriangleAA (fVec2 P1, fVec2 P2, fVec2 P3, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled triangle with a thick border of a different color [High quality]. More...
 
Drawing primitives: triangles (SPECIAL METHODS).

ADVANCED METHODS USING THE 3D RASTERIZER BACKEND.

Remarks
  1. These method use sub-pixel precision (but not anti-aliasing).
  2. Sprite images and gradient colors can have different types from the destination (ie this) image.
template<typename color_alt >
void drawGradientTriangle (fVec2 P1, fVec2 P2, fVec2 P3, color_alt colorP1, color_alt colorP2, color_alt colorP3, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a triangle with gradient color specified by the colors on its vertices. More...
 
template<typename color_t_tex >
void drawTexturedTriangle (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw textured triangle onto the image. More...
 
template<typename color_t_tex , typename BLEND_OPERATOR >
void drawTexturedTriangle (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, const BLEND_OPERATOR &blend_op)
 Blend a textured triangle onto the image. More...
 
template<typename color_t_tex >
void drawTexturedGradientTriangle (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, color_t_tex C1, color_t_tex C2, color_t_tex C3, float opacity=TGX_DEFAULT_NO_BLENDING)
 Blend textured triangle on the image while combining it with a color gradient. More...
 
template<typename color_t_tex >
void drawTexturedMaskedTriangle (const Image< color_t_tex > &src_im, color_t_tex transparent_color, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, float opacity=1.0f)
 Blend textured triangle with a transparency mask (ie a specific color is treated as fully transparent) More...
 
template<typename color_t_tex >
void drawTexturedGradientMaskedTriangle (const Image< color_t_tex > &src_im, color_t_tex transparent_color, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, color_t_tex C1, color_t_tex C2, color_t_tex C3, float opacity=1.0f)
 Blend textured triangle with a transparency mask (ie a specific color is treated as fully transparent) and blend it with a color gradient... More...
 
Drawing primitives: quads.

FAST/REGULAR METHODS

void drawQuad (iVec2 P1, iVec2 P2, iVec2 P3, iVec2 P4, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a quad. More...
 
void fillQuad (iVec2 P1, iVec2 P2, iVec2 P3, iVec2 P4, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 draw a filled quad. More...
 
Drawing primitives: quads (AA).

HIGH QUALITY DRAWING

void drawQuadAA (fVec2 P1, fVec2 P2, fVec2 P3, fVec2 P4, color_t color, float opacity=1.0f)
 Draw a quad [High quality]. More...
 
void drawThickQuadAA (fVec2 P1, fVec2 P2, fVec2 P3, fVec2 P4, float thickness, color_t color, float opacity=1.0f)
 Draw a quad with a thick border [High quality]. More...
 
void fillQuadAA (fVec2 P1, fVec2 P2, fVec2 P3, fVec2 P4, color_t color, float opacity=1.0f)
 Draw a filled quad [High quality]. More...
 
void fillThickQuadAA (fVec2 P1, fVec2 P2, fVec2 P3, fVec2 P4, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled quad with a thick border of a different color [High quality]. More...
 
Drawing primitives: quads (SPECIAL METHODS).

ADVANCED METHODS USING THE 3D RASTERIZER BACKEND.

Remarks
  1. These method use sub-pixel precision (but not anti-aliasing).
  2. Sprite images and gradient colors can have different types from the destination (ie this) image.
template<typename color_alt >
void drawGradientQuad (fVec2 P1, fVec2 P2, fVec2 P3, fVec2 P4, color_alt colorP1, color_alt colorP2, color_alt colorP3, color_alt colorP4, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a quad with a gradient color specified by the color at the four vertices. More...
 
template<typename color_t_tex >
void drawTexturedQuad (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 srcP4, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, fVec2 dstP4, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a textured quad using bilinear filtering. More...
 
template<typename color_t_tex , typename BLEND_OPERATOR >
void drawTexturedQuad (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 srcP4, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, fVec2 dstP4, const BLEND_OPERATOR &blend_op)
 Draw a textured quad with bilinear filtering and a custom blending operator. More...
 
template<typename color_t_tex >
void drawTexturedGradientQuad (const Image< color_t_tex > &src_im, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 srcP4, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, fVec2 dstP4, color_t_tex C1, color_t_tex C2, color_t_tex C3, color_t_tex C4, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a textured quad using bilinear filtering combined with a color gradient. More...
 
template<typename color_t_tex >
void drawTexturedMaskedQuad (const Image< color_t_tex > &src_im, color_t_tex transparent_color, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 srcP4, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, fVec2 dstP4, float opacity=1.0f)
 Draw a textured quad using bilinear filtering and with a mask (ie a fixed transparent color). More...
 
template<typename color_t_tex >
void drawTexturedGradientMaskedQuad (const Image< color_t_tex > &src_im, color_t_tex transparent_color, fVec2 srcP1, fVec2 srcP2, fVec2 srcP3, fVec2 srcP4, fVec2 dstP1, fVec2 dstP2, fVec2 dstP3, fVec2 dstP4, color_t_tex C1, color_t_tex C2, color_t_tex C3, color_t_tex C4, float opacity=1.0f)
 Draw a textured quad using bilinear filtering and with a mask (ie a fixed transparent color) and combined with a color gradient. More...
 
Drawing primitives: polylines.

FAST/REGULAR METHODS

void drawPolyline (int nbpoints, const iVec2 tabPoints[], color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn]. More...
 
template<typename FUNCTOR_NEXT >
void drawPolyline (FUNCTOR_NEXT next_point, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn]. More...
 
Drawing primitives: polylines (AA).

HIGH QUALITY DRAWING

void drawPolylineAA (int nbpoints, const fVec2 tabPoints[], color_t color, float opacity=1.0f)
 Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality). More...
 
template<typename FUNCTOR_NEXT >
void drawPolylineAA (FUNCTOR_NEXT next_point, color_t color, float opacity=1.0f)
 Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality). More...
 
void drawThickPolylineAA (int nbpoints, const fVec2 tabPoints[], float thickness, EndPath end_P0, EndPath end_Pn, color_t color, float opacity=1.0f)
 Draw a thick polyline ie a sequence of consecutif thick segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality). More...
 
template<typename FUNCTOR_NEXT >
void drawThickPolylineAA (FUNCTOR_NEXT next_point, float thickness, EndPath end_P0, EndPath end_Pn, color_t color, float opacity=1.0f)
 Draw a thick polyline ie a sequence of consecutif thick segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality). More...
 
Drawing primitives: polygons.

FAST/REGULAR METHODS

void drawPolygon (int nbpoints, const iVec2 tabPoints[], color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a closed polygon with vertices [P0,P2,,, PN]. More...
 
template<typename FUNCTOR_NEXT >
void drawPolygon (FUNCTOR_NEXT next_point, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a closed polygon with vertices [P0,P2,,, PN]. More...
 
void fillPolygon (int nbpoints, const iVec2 tabPoints[], color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled polygon with vertices [P0,P2,,, PN]. More...
 
template<typename FUNCTOR_NEXT >
void fillPolygon (FUNCTOR_NEXT next_point, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled polygon with vertices [P0,P2,,, PN]. More...
 
Drawing primitives: polygons (AA).

HIGH QUALITY DRAWING

void drawPolygonAA (int nbpoints, const fVec2 tabPoints[], color_t color, float opacity=1.0f)
 Draw a closed polygon with vertices [P0,P2,,, PN] (High quality). More...
 
template<typename FUNCTOR_NEXT >
void drawPolygonAA (FUNCTOR_NEXT next_point, color_t color, float opacity=1.0f)
 Draw a closed polygon with vertices [P0,P2,,, PN] (High quality). More...
 
void drawThickPolygonAA (int nbpoints, const fVec2 tabPoints[], float thickness, color_t color, float opacity=1.0f)
 Draw a polygon with thick lines (High quality). More...
 
template<typename FUNCTOR_NEXT >
void drawThickPolygonAA (FUNCTOR_NEXT next_point, float thickness, color_t color, float opacity=1.0f)
 Draw a polygon with thick lines (High quality). More...
 
void fillPolygonAA (int nbpoints, const fVec2 tabPoints[], color_t color, float opacity=1.0f)
 Draw a filled polygon (High quality). More...
 
template<typename FUNCTOR_NEXT >
void fillPolygonAA (FUNCTOR_NEXT next_point, color_t color, float opacity=1.0f)
 Draw a filled polygon (High quality). More...
 
void fillThickPolygonAA (int nbpoints, const fVec2 tabPoints[], float thickness, color_t interior_color, color_t border_color, float opacity=1.0f)
 Draw a filled polygon with a thick border of a different color (High quality). More...
 
template<typename FUNCTOR_NEXT >
void fillThickPolygonAA (FUNCTOR_NEXT next_point, float thickness, color_t interior_color, color_t border_color, float opacity=1.0f)
 Draw a filled polygon with a thick border of a different color (High quality). More...
 
Drawing primitives: circles.

FAST/REGULAR METHODS

void drawCircle (iVec2 center, int r, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a circle. More...
 
void fillCircle (iVec2 center, int r, color_t interior_color, color_t outline_color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled circle with different colors for outline and interior. More...
 
Drawing primitives: circles (AA).

HIGH QUALITY DRAWING

void drawCircleAA (fVec2 center, float r, color_t color, float opacity=1.0f)
 Draw a circle (high quality). More...
 
void drawThickCircleAA (fVec2 center, float r, float thickness, color_t color, float opacity=1.0f)
 Draw a circle with a thick border (high quality). More...
 
void fillCircleAA (fVec2 center, float r, color_t color, float opacity=1.0f)
 Draw a filled circle (high quality). More...
 
void fillThickCircleAA (fVec2 center, float r, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled circle with a thick border of a different color (high quality). More...
 
Drawing primitives: arcs and pies (AA).

HIGH QUALITY DRAWING

void drawCircleArcAA (fVec2 center, float r, float angle_start, float angle_end, color_t color, float opacity=1.0f)
 Draw a circle arc (high quality). More...
 
void drawThickCircleArcAA (fVec2 center, float r, float angle_start, float angle_end, float thickness, color_t color, float opacity=1.0f)
 Draw a circle arc with a thick border (high quality). More...
 
void fillCircleSectorAA (fVec2 center, float r, float angle_start, float angle_end, color_t color, float opacity=1.0f)
 Draw a filled circle sector/slice/pie (high quality). More...
 
void fillThickCircleSectorAA (fVec2 center, float r, float angle_start, float angle_end, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled circle sector/slice/pie with a thick border of a different color (high quality). More...
 
Drawing primitives: ellipses

FAST/REGULAR METHODS

void drawEllipse (iVec2 center, iVec2 radiuses, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw an ellipse. More...
 
void fillEllipse (iVec2 center, iVec2 radiuses, color_t interior_color, color_t outline_color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a filled ellipse with different colors for the outline and the interior. More...
 
Drawing primitives: ellipses (AA).

HIGH QUALITY DRAWING

void drawEllipseAA (fVec2 center, fVec2 radiuses, color_t color, float opacity=1.0f)
 Draw an ellipse (high quality). More...
 
void drawThickEllipseAA (fVec2 center, fVec2 radiuses, float thickness, color_t color, float opacity=1.0f)
 Draw an ellipse with a thick border (high quality). More...
 
void fillEllipseAA (fVec2 center, fVec2 radiuses, color_t color, float opacity=1.0f)
 Draw a filled ellipse (high quality). More...
 
void fillThickEllipseAA (fVec2 center, fVec2 radiuses, float thickness, color_t color_interior, color_t color_border, float opacity=1.0f)
 Draw a filled ellipse with a thick border of a different color (high quality). More...
 
Drawing primitives: Bezier curves.

FAST/REGULAR METHODS

void drawQuadBezier (iVec2 P1, iVec2 P2, iVec2 PC, float wc, bool drawP2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a quadratic (rational) Bezier curve. More...
 
void drawCubicBezier (iVec2 P1, iVec2 P2, iVec2 PA, iVec2 PB, bool drawP2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a cubic Bezier curve. More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawQuadSpline (int nbpoints, const iVec2 tabPoints[], bool draw_last_point, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a quadratic spline interpolating between a given set of points. More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawCubicSpline (int nbpoints, const iVec2 tabPoints[], bool draw_last_point, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a cubic spline interpolating between a given set of points. More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawClosedSpline (int nbpoints, const iVec2 tabPoints[], color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a closed quadratic spline interpolating between a given set of points. More...
 
Drawing primitives: Bezier curves (AA).

HIGH QUALITY DRAWING

void drawThickQuadBezierAA (fVec2 P1, fVec2 P2, fVec2 PC, float wc, float thickness, EndPath end_P1, EndPath end_P2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a thick quadratic (rational) Bezier curve (high quality). More...
 
void drawThickCubicBezierAA (fVec2 P1, fVec2 P2, fVec2 PA, fVec2 PB, float thickness, EndPath end_P1, EndPath end_P2, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a thick cubic Bezier curve (high quality). More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawThickQuadSplineAA (int nbpoints, const fVec2 tabPoints[], float thickness, EndPath end_P0, EndPath end_Pn, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a thick quadratic spline interpolating between a given set of points (high quality). More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawThickCubicSplineAA (int nbpoints, const fVec2 tabPoints[], float thickness, EndPath end_P0, EndPath end_Pn, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a thick cubic spline interpolating between a given set of points (high quality). More...
 
template<int SPLINE_MAX_POINTS = 32>
void drawThickClosedSplineAA (int nbpoints, const fVec2 tabPoints[], float thickness, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a thick closed quadratic spline interpolating between a given set of points (high quality). More...
 
template<int SPLINE_MAX_POINTS = 32>
void fillClosedSplineAA (int nbpoints, const fVec2 tabPoints[], color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Fill a region delimited by a closed quadratic spline (high quality). More...
 
template<int SPLINE_MAX_POINTS = 32>
void fillThickClosedSplineAA (int nbpoints, const fVec2 tabPoints[], float thickness, color_t color_interior, color_t color_border, float opacity=TGX_DEFAULT_NO_BLENDING)
 Fill a region delimited by a closed thick quadratic spline where the interior and boundary can have different colors (high quality). More...
 
Drawing primitives: Text

The following font formats are supported:

Note
tgx-font (https://github.com/vindar/tgx-font) contains a collection ILI9341_t3 v1 and v2 (antialiased) fonts that can be used directly with the methods below (and the instruction on how to convert a ttf font to this format).
int fontHeight (const GFXfont &font) const
 Query the height of a font. More...
 
int fontHeight (const ILI9341_t3_font_t &font) const
 Query the height of a font. More...
 
iBox2 measureChar (char c, iVec2 pos, const GFXfont &font, Anchor anchor=DEFAULT_TEXT_ANCHOR, int *xadvance=nullptr) const
 Compute the bounding box of a character. More...
 
iBox2 measureChar (char c, iVec2 pos, const ILI9341_t3_font_t &font, Anchor anchor=DEFAULT_TEXT_ANCHOR, int *xadvance=nullptr) const
 Compute the bounding box of a character. More...
 
iBox2 measureText (const char *text, iVec2 pos, const GFXfont &font, Anchor anchor=DEFAULT_TEXT_ANCHOR, bool wrap_text=false, bool start_newline_at_0=false) const
 Compute the bounding box of a text. More...
 
iBox2 measureText (const char *text, iVec2 pos, const ILI9341_t3_font_t &font, Anchor anchor=DEFAULT_TEXT_ANCHOR, bool wrap_text=false, bool start_newline_at_0=false) const
 Compute the bounding box of a text. More...
 
iVec2 drawChar (char c, iVec2 pos, const GFXfont &font, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a single character at position pos on the image and return the position for the next character. More...
 
iVec2 drawChar (char c, iVec2 pos, const ILI9341_t3_font_t &font, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a single character at position pos on the image and return the position for the next character. More...
 
iVec2 drawText (const char *text, iVec2 pos, const GFXfont &font, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a text at a given position with a given font. More...
 
iVec2 drawText (const char *text, iVec2 pos, const ILI9341_t3_font_t &font, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Draw a text at a given position with a given font. More...
 
iVec2 drawTextEx (const char *text, iVec2 pos, Anchor anchor, const GFXfont &font, bool wrap_text, bool start_newline_at_0, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Advanced drawText method. More...
 
iVec2 drawTextEx (const char *text, iVec2 pos, Anchor anchor, const ILI9341_t3_font_t &font, bool wrap_text, bool start_newline_at_0, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
 Advanced drawText method. More...
 

Static Public Attributes

static const int DEFAULT_STRIDE = -1
 If not specified, the stride of an image is equal to its width.
 

Detailed Description

template<typename color_t>
class tgx::Image< color_t >

Image class [MAIN CLASS FOR THE 2D API].

This is the main image class for the TGX library.

An image object is a thin wrapper (only 16 bytes) around a memory buffer which defines the type and dimension of the image.

Template Parameters
color_tColor type of the image. Must be one of the color type defined in Color.h. Typical choice:
  • RGB32 when running on a desktop computer.
  • RGB565 when running on an MCU with limited memory (Teensy 4, ESP32..)

Image memory layout

The image in the memory buffer in made of consecutive pixel of type color_t in row major order but with a stride which may be larger than the image width (ie row lenght).

Pixels are ordered from the top left (0,0) to the bottom right (_lx-1, _ly-1) and the position of pixel (x,y) in the buffer is given by the formula:

pixel(x,y) = buffer[x + y * _stride].
Note
No memory allocation is ever perfomed by the Image class. It is the sole user repsonsability to allocated et free the pixel buffer
Remarks
  1. When creating a new image, one can (and usually should) choose _stride = lx. However, allowing other strides in the class definition allows to efficiently represent sub-images without making a copy and thus enables fast clipping of all drawing operations (sub-images are similar to Numpy view for ndarray).
  2. Avoid using HSV as color type for an image: it has not been tested to work and will be very slow.
  3. The library defines many drawing primitives with naming convention:

    [draw/fill][Thick/-]MethodName[AA/-]
    int fill(iVec2 start_pos, color_t new_color)
    'Flood fill' a 4-connected region of the image.

    where

    • [draw] means that the method draw a path whereas [fill] means that the method create a solid shape.
    • [thick] means that the outline of the shape has selectable thickness (not just a single pixel wide). The tickness is usually a float and should be at least 1.
    • [AA] means that the method is high quality: it is drawn with anti-aliasing and sub-pixel precision. Method with this suffix take fVec2 parameters for coordinates inputs whereas regular 'low quality' methods (without the AA suffix) take iVec2 parameters.

    For example:

    • drawThickCircleAA() : draw a high quality circle with user defined outline thickness, antialiasing and sub-pixel precison.
    • fillTriangle() : draw a low quality filled triangle (no antialiasing or subpixel precision).
  4. All drawing methods that take a color parameter also take an opacity float parameter which allows to add transparency effects even when color type used do not have an alpha channel:
    • Passing TGX_DEFAULT_NO_BLENDING or a negative value for the opacity will disable blending so the method will simply use overwritting of the destination pixels.
    • Passing 0.0f < opacity <= 1.0f will enable blending and the alpha channel of the colors will be used if present.
  5. As indicated in color.h. All colors with an alpha channel are assumed to have pre-multiplied alpha and treated as such for all blending operations cf: https://en.wikipedia.org/wiki/Alpha_compositing
  6. Most methods take iVec2/fVec2 parameters to specify coordinates in the image. Using initializer list, it is very easy to call such method without explicitly mentioning the iVec2/fVec2 type. For example, a function with signature f(iVec2 pos, int r) can be simply called f({x,y},z) which is equivalent to the expression f(iVec2(x,y),z).

    Note
    iVec2 vectors are automatically promoted to fVec2 vectors so calling a method with sub-pixel precision is transparent when working with integer vectors iVec2. On the other hand, downgrading from fVec2 to iVec2 requires an explicit cast.
  7. Creating sub-image is cheap and convenient to restrict a drawing operation to a rectangular region of an image. Do not refrain from creating sub-images!

Constructor & Destructor Documentation

◆ Image() [1/5]

template<typename color_t >
tgx::Image< color_t >::Image ( )

Default constructor.

Create a empty (invalid) image.

◆ Image() [2/5]

template<typename color_t >
template<typename T >
tgx::Image< color_t >::Image ( T *  buffer,
int  lx,
int  ly,
int  stride = DEFAULT_STRIDE 
)

Constructor.

Creates an image with a given size and a given buffer.

Parameters
bufferthe image buffer.
lxthe image width.
lythe image height.
stride(Optional) the stride to use (equal to the image width if not specified).

◆ Image() [3/5]

template<typename color_t >
template<typename T >
tgx::Image< color_t >::Image ( T *  buffer,
iVec2  dim,
int  stride = DEFAULT_STRIDE 
)

Constructor.

Creates an image with a given size and a given buffer.

Parameters
bufferthe image buffer.
dimthe image dimension (width, height) in pixels.
stridethe stride to use (equal to the image width if not specified).

◆ Image() [4/5]

template<typename color_t >
tgx::Image< color_t >::Image ( const Image< color_t > &  im,
iBox2  subbox 
)

Constructor.

Create a sub-image of a given image sharing the same buffer.

Parameters
imThe source image.
subboxThe region of the source image to use for this image.

◆ Image() [5/5]

template<typename color_t >
tgx::Image< color_t >::Image ( const Image< color_t > &  im)
default

Default copy constructor.

Copy is shallow: both images share the same memory buffer.

Parameters
imThe source image.

Member Function Documentation

◆ operator=()

template<typename color_t >
Image & tgx::Image< color_t >::operator= ( const Image< color_t > &  im)
default

Default assignement operator.

Copy is shallow: both images share the same memory buffer.

Parameters
imThe source image.
Returns
itself.

◆ set() [1/2]

template<typename color_t >
template<typename T >
void tgx::Image< color_t >::set ( T *  buffer,
int  lx,
int  ly,
int  stride = DEFAULT_STRIDE 
)

Set/update the image parameters.

Parameters
bufferthe pixel buffer.
lximage width.
lyimage height.
stride(Optional) The stride. If not specified, the stride is set equal to the image width.

◆ set() [2/2]

template<typename color_t >
template<typename T >
void tgx::Image< color_t >::set ( T *  buffer,
iVec2  dim,
int  stride = DEFAULT_STRIDE 
)

Set/update the image parameters.

Parameters
bufferthe pixel buffer.
dimthe image dimensions.
stride(Optional) The stride. If not specified, the stride is set equal to the image width.

◆ crop()

template<typename color_t >
void tgx::Image< color_t >::crop ( const iBox2 subbox)

Crop the image.

Crop this image keeping only the region represented by subbox intersected with the image box.

This operation does not change the underlying pixel buffer: it simply replaces this image by a sub-image of itself (with different dimension/stride).

Parameters
subboxThe region to to keep.

◆ getCrop()

template<typename color_t >
Image< color_t > tgx::Image< color_t >::getCrop ( const iBox2 subbox) const

Return a sub-image of this image (sharing the same pixel buffer).

See also operator() below.

Parameters
subboxThe region to to keep.
Returns
the cropped image.

◆ operator()() [1/6]

template<typename color_t >
Image< color_t > tgx::Image< color_t >::operator() ( const iBox2 B) const

Return a sub-image of this image (sharing the same pixel buffer).

This is the same as getCrop(B)

Parameters
Bbox that delimit the sub-image inside this image.
Returns
the sub-image delimited by B and sharing the same memory buffer.

◆ operator()() [2/6]

template<typename color_t >
Image< color_t > tgx::Image< color_t >::operator() ( int  min_x,
int  max_x,
int  min_y,
int  max_y 
) const

Return a sub-image of this image (sharing the same pixel buffer).

This is the same as getCrop(tgx::iBox2(min_x, max_x, min_y, max_x)) or operator()(tgx::iBox2(min_x, max_x, min_y, max_x))

Parameters
min_xleft boundary (inclusive)
max_xright boundary (inclusive)
min_ytop boundary (inclusive)
max_ybottom boundary (inclusive)
Returns
the sub-image delimited the closed box iBox(min_x, max_x, min_y, max_x) and sharing the same memory buffer.

◆ isValid()

template<typename color_t >
TGX_INLINE bool tgx::Image< color_t >::isValid ( ) const
inline

Query if the image is valid.

Returns
True if the image if valid, false otherwise.

◆ setInvalid()

template<typename color_t >
void tgx::Image< color_t >::setInvalid ( )

Set the image as invalid.

Note
It is the user responsibility to manage the memory allocated for the pixel buffer (if required). No deallocation is performed here.

◆ width()

template<typename color_t >
TGX_INLINE int tgx::Image< color_t >::width ( ) const
inline

Return the image width.

Same as lx().

Returns
The image width (0 for an invalid image).

◆ lx()

template<typename color_t >
TGX_INLINE int tgx::Image< color_t >::lx ( ) const
inline

Return the image width.

Same as width().

Returns
The image width (0 for an invalid image).

◆ height()

template<typename color_t >
TGX_INLINE int tgx::Image< color_t >::height ( ) const
inline

Return the image height.

Same as ly().

Returns
The image height (0 for an invalid image).

◆ ly()

template<typename color_t >
TGX_INLINE int tgx::Image< color_t >::ly ( ) const
inline

Return the image height.

Same as height().

Returns
The image height (0 for an invalid image).

◆ stride()

template<typename color_t >
TGX_INLINE int tgx::Image< color_t >::stride ( ) const
inline

Return the image stride.

Returns
The stride (0 for an invalid image).

◆ dim()

template<typename color_t >
TGX_INLINE iVec2 tgx::Image< color_t >::dim ( ) const
inline

Return the image dimensions as an iVec2.

Returns
The image dimension (returns {0,0} for an invalid image).

◆ imageBox()

template<typename color_t >
TGX_INLINE iBox2 tgx::Image< color_t >::imageBox ( ) const
inline

Return the image dimension as a box.

Returns
a box of the form {0, width-1, 0 height-1 } or an empty box if the image is invalid.

◆ data() [1/2]

template<typename color_t >
TGX_INLINE const color_t * tgx::Image< color_t >::data ( ) const
inline

Return a pointer to the pixel buffer.

const overload.

Returns
A const pointer to the start of the pixel buffer associated with this image (or nullptr if the image is invalid).

◆ data() [2/2]

template<typename color_t >
TGX_INLINE color_t * tgx::Image< color_t >::data ( )
inline

Return a pointer to the pixel buffer.

non-const overload.

Returns
A pointer to the start of the pixel buffer associated with this image (or nullptr if the image is invalid).

◆ drawPixel() [1/2]

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE void tgx::Image< color_t >::drawPixel ( iVec2  pos,
color_t  color 
)
inline

Set a pixel at a given position.

Template Parameters
CHECKRANGEset to false to disable range checking (danger!)
Parameters
posposition.
colorcolor to set.

◆ drawPixelf() [1/2]

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE void tgx::Image< color_t >::drawPixelf ( fVec2  pos,
color_t  color 
)
inline

Set a pixel at a given position (floating point coord).

Remarks
Version for floating point value coordinates. Recall that the image range is [-0.5f, lx-0.5f]x[-0.5f,lx-0.5f] and center of pixels are on the interger lattice.
Template Parameters
CHECKRANGEset to false to disable range checking (danger!)
Parameters
posposition given as a floating point value vector.
colorcolor to set.

◆ drawPixel() [2/2]

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE void tgx::Image< color_t >::drawPixel ( iVec2  pos,
color_t  color,
float  opacity 
)
inline

Blend a pixel with the current pixel color.

Remarks
If type color_t has an alpha channel, then it is used for alpha blending.
Template Parameters
CHECKRANGEset to false to disable range checking (danger!)
Parameters
posThe position.
colorThe color to blend.
opacityopacity multiplier from 0.0f (fully transparent) to 1.0f fully transparent. if negative, then simple overwriting of color is used instead of blending.

◆ drawPixelf() [2/2]

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE void tgx::Image< color_t >::drawPixelf ( fVec2  pos,
color_t  color,
float  opacity 
)
inline

Blend a pixel with the current pixel color (floating point coord).

Remarks
  • Version for floating point value coordinates. Recall that the image range is [-0.5f, lx-0.5f]x[-0.5f,lx-0.5f] and center of pixels are on the interger lattice.
  • If type color_t has an alpha channel, then it is used for alpha blending.
Template Parameters
CHECKRANGEset to false to disable range checking (danger!)
Parameters
posThe position given as a floating point value vector.
colorThe color to blend.
opacityopacity multiplier from 0.0f (fully transparent) to 1.0f fully transparent. if negative, then simple overwriting of color is used instead of blending.

◆ readPixel()

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE color_t tgx::Image< color_t >::readPixel ( iVec2  pos,
color_t  outside_color = color_t() 
) const
inline

Return the color of a pixel at a given position.

Template Parameters
CHECKRANGEIf set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!)
Parameters
posThe position to read.
outside_color(Optional) color to return when querying outside the range.
Returns
The pixel color.

◆ readPixelf()

template<typename color_t >
template<bool CHECKRANGE = true>
TGX_INLINE color_t tgx::Image< color_t >::readPixelf ( fVec2  pos,
color_t  outside_color = color_t() 
) const
inline

Return the color of a pixel at a given position (floating point coord).

Remarks
Version for floating point value coordinates. Recall that the image range is [-0.5f, lx-0.5f]x[-0.5f,lx-0.5f] and center of pixels are on the interger lattice.
Template Parameters
CHECKRANGEIf set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!)
Parameters
posThe position to read given as a floating point value vector.
outside_color(Optional) color to return when querying outside the range.
Returns
The pixel color.

◆ operator()() [3/6]

template<typename color_t >
TGX_INLINE const color_t & tgx::Image< color_t >::operator() ( iVec2  pos) const
inline

Get a reference to a pixel (no range check!)

const overload.

Parameters
posThe position.
Returns
a const reference to the pixel color.

◆ operator()() [4/6]

template<typename color_t >
TGX_INLINE color_t & tgx::Image< color_t >::operator() ( iVec2  pos)
inline

Get a reference to a pixel (no range check!)

non-const overload.

Parameters
posThe position.
Returns
a reference to the pixel color.

◆ operator()() [5/6]

template<typename color_t >
TGX_INLINE const color_t & tgx::Image< color_t >::operator() ( int  x,
int  y 
) const
inline

Get a reference to a pixel (no range check!)

const overload.

Parameters
xx-coordinate.
yy-coordinate.
Returns
a const reference to the pixel color.

◆ operator()() [6/6]

template<typename color_t >
TGX_INLINE color_t & tgx::Image< color_t >::operator() ( int  x,
int  y 
)
inline

Get a reference to a pixel (no range check!)

non-const overload.

Parameters
xx-coordinate.
yy-coordinate.
Returns
a reference to the pixel color.

◆ iterate() [1/4]

template<typename color_t >
template<typename ITERFUN >
void tgx::Image< color_t >::iterate ( ITERFUN  cb_fun)

Iterate over all the pixels of the image.

non-const overload.

Iteration is performed from left to right (inner loop) and top to bottom (outer loop). The callback function cb_fun() is called for each pixel and must have a signature compatible with:

bool cb_fun(tgx::iVec2 pos, color_t & color)

where:

  • pos is the position of the current pixel in the image
  • color is a reference to the current pixel color.
  • the callback must return true to continue the iteration and false to abort iteration.
Remarks
this method is particularly useful with lambdas, for example, to paint all black pixels to red in a tgx::Image<tgx::RGB565> image im:
im.iterate( [](tgx::iVec2 pos, tgx::RGB565 & color)
{ if (color == tgx::RGB565_Black) color = tgx::RGB565_Red; return true; } );
Color in R5/G6/B5 format.
Definition: Color.h:202
Generic 2D vector [specializations iVec2, fVec2, dVec2].
Definition: Vec2.h:64
Parameters
cb_funThe callback function.

◆ iterate() [2/4]

template<typename color_t >
template<typename ITERFUN >
void tgx::Image< color_t >::iterate ( ITERFUN  cb_fun) const

Iterate over all the pixels of the image.

const overload.

Iteration is performed from left to right (inner loop) and top to bottom (outer loop). The callback function cb_fun() is called for each pixel and must have a signature compatible with:

bool cb_fun(tgx::iVec2 pos, const color_t & color)

see void iterate(ITERFUN cb_fun) for details.

Parameters
cb_funThe callback function.

◆ iterate() [3/4]

template<typename color_t >
template<typename ITERFUN >
void tgx::Image< color_t >::iterate ( ITERFUN  cb_fun,
tgx::iBox2  B 
)

Iterate over the pixel of the image inside a given region.

non-const overload.

The method calls the callback function for each pixel inside B (intersected with imageBox()).

See void iterate(ITERFUN cb_fun) for details.

Parameters
cb_funThe callback function.
BThe sub-box to iterate inside.

◆ iterate() [4/4]

template<typename color_t >
template<typename ITERFUN >
void tgx::Image< color_t >::iterate ( ITERFUN  cb_fun,
tgx::iBox2  B 
) const

Iterate over the pixel of the image inside a given region.

const overload.

The method calls the callback function for each pixel inside B (intersected with imageBox()).

See void iterate(ITERFUN cb_fun) for details.

Parameters
cb_funThe callback function.
BThe sub-box to iterate inside.

◆ blit() [1/2]

template<typename color_t >
void tgx::Image< color_t >::blit ( const Image< color_t > &  sprite,
iVec2  upperleftpos,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Blit/blend a sprite over this image at a given position.

Remark: If only part of the sprite should be blended onto this image, simply blit a sub-image of the sprite like so: 'blend(sprite(subbox),upperleftpos, blend_op)'. This is very efficient because no copy is performed when creating (shallow) sub-image.

Parameters
spriteThe sprite image to blit.
upperleftposPosition of the upper left corner of the sprite in the image.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply overwrite the spite over the image.

◆ blit() [2/2]

template<typename color_t >
template<typename color_t_src , typename BLEND_OPERATOR >
void tgx::Image< color_t >::blit ( const Image< color_t_src > &  sprite,
iVec2  upperleftpos,
const BLEND_OPERATOR &  blend_op 
)

Blend a sprite at a given position on the image using a custom blending operator.

The blending operator 'blend_op' can be a function/functor/lambda. It takes as input the color of the source (sprite) pixel and the color of the destination pixel and returns the blended color. It must have a signature compatible with

               color_t blend_op(color_t_src src, color_t dst)

(the method can, in fact, return a color of any type but returning type color_t will improve performance).

Remarks
  1. The sprite can have a different color type from the image.
  2. To perform "classical alpha blending", use the blit() method with an opacity parameter instead of this method as it will be faster.
Parameters
spriteThe sprite image to blend.
upperleftposPosition of the upper left corner of the sprite in the image.
blend_opThe blending operator.

◆ blitRotated() [1/2]

template<typename color_t >
void tgx::Image< color_t >::blitRotated ( const Image< color_t > &  sprite,
iVec2  upperleftpos,
int  angle,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Blit/blend a rotated sprite over this image at a given position.

The rotation must be only quarter turns (0, 90, 180 or 270) degree. For blitting with arbitrary rotation, use the blitScaledRotated() method instead.

Parameters
spriteThe sprite image to blit.
upperleftposPosition inside this image of the upper left corner of the sprite (after rotation).
angleCounter-clockwise angle to rotate the sprite prior to blitting. Must be either 0, 90, 180 or 270.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply overwrite the spite over the image.

◆ blitRotated() [2/2]

template<typename color_t >
template<typename color_t_src , typename BLEND_OPERATOR >
void tgx::Image< color_t >::blitRotated ( const Image< color_t_src > &  sprite,
iVec2  upperleftpos,
int  angle,
const BLEND_OPERATOR &  blend_op 
)

Blend a rotated sprite over this image at a given position using a custom blending operator.

The rotation must be only quarter turns (0, 90, 180 or 270) degree. For blitting with arbitrary rotation, use the blitScaledRotated() method instead.

The blending operator 'blend_op' can be a function/functor/lambda. It takes as input the color of the source (sprite) pixel and the color of the destination pixel and returns the blended color. It must have a signature compatible with

               color_t blend_op(color_t_src src, color_t dst)

(the method can, in fact, return a color of any type but returning type color_t will improve performance).

Remarks
  1. The sprite can have a different color type from the image.
  2. To perform "classical alpha blending", use the blit() method with an opacity parameter instead of this method as it will be faster.
Parameters
spriteThe sprite image to blit.
upperleftposPosition inside this image of the upper left corner of the sprite (after rotation).
angleCounter-clockwise angle to rotate the sprite prior to blitting. Must be either 0, 90, 180 or 270.
blend_opThe blending operator.

◆ blitMasked()

template<typename color_t >
void tgx::Image< color_t >::blitMasked ( const Image< color_t > &  sprite,
color_t  transparent_color,
iVec2  upperleftpos,
float  opacity = 1.0f 
)

Blend a sprite at a given position on this image with a given mask.

Sprite pixels with color transparent_color are treated as transparent hence are not copied on the image. Other pixels are copied/blended with the destination image (after being multiplied by the opacity factor).

Remarks
This method is especially useful when color_t does not have an alpha channel.
Parameters
spriteThe sprite image to blit.
transparent_colorThe sprite color considered transparent.
upperleftposPosition of the upper left corner of the sprite in the image.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply draw the sprite over the image.

◆ blitBackward()

template<typename color_t >
void tgx::Image< color_t >::blitBackward ( Image< color_t > &  dst_sprite,
iVec2  upperleftpos 
) const

Reverse blitting.

Copy part of the image into the sprite This is the inverse of the blit operation.

Remarks
This method can be useful to 'save' a portion of the image into a sprite before drawing/blitting something on it...
Parameters
[in,out]dst_spriteThe sprite to save part of this image into.
upperleftposPosition of the upper left corner of the sprite in the image.

◆ blitScaledRotated() [1/2]

template<typename color_t >
template<typename color_t_src , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void tgx::Image< color_t >::blitScaledRotated ( const Image< color_t_src >  src_im,
fVec2  anchor_src,
fVec2  anchor_dst,
float  scale = 1.0f,
float  angle_degrees = 0.0f,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Blit/blend a sprite onto this image after rescaling and rotation.

The anchor point 'anchor_src' in the sprite is mapped to 'anchor_im' in this image. The rotation is performed in counter-clockwise direction around the anchor point.

Remarks
  1. Positions are given using floating point values to allow for sub-pixel precision for smoother animation.
  2. The method uses bilinear interpolation for high quality rendering.
  3. The sprite image can have a different color type from this image.
Note
When rotated, access to the sprite pixels colors is not linear anymore. For certain orientations, this will yield very 'irregular' access to the sprite memory locations. The method will try to improve this by splitting the sprite in smaller part to improve cache access. If this does not help, try moving the sprite to a faster memory location
Template Parameters
CACHE_SIZESize of the MCU cache when reading from flash. This value is indicative and used to optimize cache access to flash memory. You may try changing the default value it if drawing takes a long time...
Parameters
src_imThe sprite image to draw.
anchor_srcPosition of the anchor point in the sprite image.
anchor_dstPosition of the anchor point in this image.
scale(Optional) Scaling factor (default 1.0f for no rescaling).
angle_degrees(Optional) The rotation angle in degrees (counter-clockwise, default 0 for no rotation).
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ blitScaledRotated() [2/2]

template<typename color_t >
template<typename color_t_src , typename BLEND_OPERATOR , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void tgx::Image< color_t >::blitScaledRotated ( const Image< color_t_src > &  src_im,
fVec2  anchor_src,
fVec2  anchor_dst,
float  scale,
float  angle_degrees,
const BLEND_OPERATOR &  blend_op 
)

Blend a sprite onto this image after rescaling and rotation using a custom blending operator.

This is the same as the method above excpet that it uses a user defined blending operator which takes as input the color of the source (sprite) pixel and the color of the destination pixel and returns the blended color. It must have a signature compatible with

               color_t blend_op(color_t_src src, color_t dst)

(the method can, in fact, return a color of any type but returning type color_t will improve performance).

See the method above for more details.

Template Parameters
CACHE_SIZESize of the MCU cache when reading from flash. This value is indicative and used to optimize cache access to flash memory. You may try changing the default value it if drawing takes a long time...
Parameters
src_imThe sprite image to draw.
anchor_srcPosition of the anchor point in the sprite image.
anchor_dstPosition of the anchor point in this image.
scaleScaling factor (counter-clockwise, default 1.0f for no rescaling).
angle_degreesThe rotation angle in degrees (default 0 for no rotation).
blend_opblending operator.

◆ blitScaledRotatedMasked()

template<typename color_t >
template<typename color_t_src , int CACHE_SIZE = TGX_PROGMEM_DEFAULT_CACHE_SIZE>
void tgx::Image< color_t >::blitScaledRotatedMasked ( const Image< color_t_src > &  src_im,
color_t_src  transparent_color,
fVec2  anchor_src,
fVec2  anchor_dst,
float  scale,
float  angle_degrees,
float  opacity = 1.0f 
)

Blend a sprite onto this image after rescaling and rotation and use a given color which is treated as fully transparent.

The anchor point 'anchor_src' in the sprite is mapped to 'anchor_im' in this image. The rotation is performed in counter-clockwise direction around the anchor point.

Remarks
  1. Positions are given using floating point values to allow for sub-pixel precision for smoother animation.
  2. The method uses bilinear interpolation for high quality rendering.
  3. The sprite image can have a different color type from this image.
  4. This method is useful when the sprite color type does not have an alpha channel.
Note
When rotated, access to the sprite pixels colors is not linear anymore. For certain orientations, this will yield very 'irregular' access to the sprite memory locations. The method will try to improve this by splitting the sprite in smaller part to improve cache access. If this does not help, try moving the sprite to a faster memory location
Template Parameters
CACHE_SIZESize of the MCU cache when reading from flash. This value is indicative and used to optimize cache access to flash memory. You may try changing the default value it if drawing takes a long time...
Parameters
src_imThe sprite image to draw.
transparent_colorThe sprite color considered transparent.
anchor_srcPosition of the anchor point in the sprite image.
anchor_dstPosition of the anchor point in this image.
scaleScaling factor (default 1.0f for no rescaling).
angle_degreesThe rotation angle in degrees (default 0 for no rotation).
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ copyFrom() [1/2]

template<typename color_t >
template<typename src_color_t >
void tgx::Image< color_t >::copyFrom ( const Image< src_color_t > &  src_im,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Copy (or blend) the src image onto the destination image with resizing and color conversion.

Very useful for converting image of different size and color type !

Remarks
  1. the source image is resized to match this image size. Bilinear interpolation is used to improve quality.
  2. The source and destination image may have different color type. Conversion is automatic.
Parameters
src_imThe image to copy into this image.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ copyFrom() [2/2]

template<typename color_t >
template<typename src_color_t , typename BLEND_OPERATOR >
void tgx::Image< color_t >::copyFrom ( const Image< src_color_t > &  src_im,
const BLEND_OPERATOR &  blend_op 
)

Blend the src image onto the destination image with resizing and color conversion.

Same as above but uses a user-defined blending operator to combine src over the existing image.

The blending operator 'blend_op' can be a function/functor/lambda. It takes as input the color of the source (sprite) pixel and the color of the destination pixel and returns the blended color. It must have a signature compatible with

               color_t blend_op(color_t_src src, color_t dst)

(the method can, in fact, return a color of any type but returning type color_t will improve performance).

Remarks
  1. the source image is resized to match this image size. Bilinear interpolation is used to improve quality.
  2. The source and destination image may have different color type. Conversion is automatic.
  3. To perform simple copy or classical alpha blending, use the copyFrom() method with an opacity parameter instead as it will be faster.
Parameters
src_imSource image to copy onto this image.
blend_opThe blending operator.

◆ copyReduceHalf()

template<typename color_t >
Image< color_t > tgx::Image< color_t >::copyReduceHalf ( const Image< color_t > &  src_image)

Copy the source image pixels into this image, reducing it by half in the process.

The method ignores the last row/column for odd dimensions larger than 1. Resizing is done by averaging the color of the 4 neighbour pixels.

This image must be large enough to accomodate the reduced image otherwise the method returns without doing anything. The reduced image is copied from the top-left corner of this image.

Note
This is an old method. Use blitScaledRotated() instead.
Parameters
src_imagethe source image.
Returns
a subimage of this image that contain the reduced image.

◆ reduceHalf()

template<typename color_t >
Image< color_t > tgx::Image< color_t >::reduceHalf ( )

Reduce this image by half.

Use the same memory buffer and keep the same stride. Resizing is done by averaging the color of the 4 neighbour pixels.

Returns
a sub-image of this image that contains the reduce image.

◆ convert()

template<typename color_t >
template<typename color_dst >
Image< color_dst > tgx::Image< color_t >::convert ( )

Convert this image to another type.

Performs 'in place' conversion of the image using the same memory buffer.

Note
The image returned may have a different stride from this image !
Warning
  1. In place conversion only possible if sizeof(color_dst) divides sizeof(color_t). Otherwise a compile time error is raised. For conversion between any two color types, one can use copyFrom().
  2. When the method returns, this image dimensions/stride are not unchange but the content of its memory buffer has been modified.
Template Parameters
color_dstColor type to convert the image into.
Returns
A new image with the same content and using the same memory framebuffer but converted to type color_dest.

◆ fillScreen()

template<typename color_t >
void tgx::Image< color_t >::fillScreen ( color_t  color)

Fill the whole image with a single color.

same as clear(color)

Parameters
colorThe color to use.

◆ clear()

template<typename color_t >
void tgx::Image< color_t >::clear ( color_t  color)

Fill the whole image with a single color.

Same as fillScreen(color).

Parameters
colorThe color to use.

◆ fillScreenVGradient()

template<typename color_t >
void tgx::Image< color_t >::fillScreenVGradient ( color_t  top_color,
color_t  bottom_color 
)

Fill the whole image with a vertical color gradient between two colors.

Interpolation takes place in RGB color space (even if color_t is HSV).

Parameters
top_colorcolor at the top of the image.
bottom_colorcolor at the bottom of the image.

◆ fillScreenHGradient()

template<typename color_t >
void tgx::Image< color_t >::fillScreenHGradient ( color_t  left_color,
color_t  right_color 
)

Fill the whole screen with an horizontal color gradient between two colors.

Interpolation takes place in RGB color space (even if color_t is HSV).

Parameters
left_colorcolor on the left side of the image.
right_colorcolor on the right side of the image.

◆ fill() [1/2]

template<typename color_t >
template<int STACK_SIZE = 1024>
int tgx::Image< color_t >::fill ( iVec2  start_pos,
color_t  new_color 
)

'Flood fill' a 4-connected region of the image.

Recolor the unicolor component containing position start_pos with the color new_color.

The template parameter can be adjusted to specify the size (in bytes) allocated on the stack. If the algorithm runs out of space, it stops without completing the filling (and return -1 to indicate failure). Otherwise, the method returns the max number of bytes used on the stack during the filling.

Template Parameters
STACK_SIZEsize allocated on the stack (in bytes).
Parameters
start_posStart position. The color to replace is the color at that position.
new_colorNew color to use.
Returns
return the max stack used (in bytes) during the algorithm. Return -1 if we run out of memory (in this case the method returns early without completing the full filling.

◆ fill() [2/2]

template<typename color_t >
template<int STACK_SIZE = 1024>
int tgx::Image< color_t >::fill ( iVec2  start_pos,
color_t  border_color,
color_t  new_color 
)

'Flood fill' a 4-connected region of the image.

Recolor the connected component containing position startpos whose boundary is delimited by border_color.

The template parameter can be adjusted to specify the size (in bytes) allocated on the stack. If the algorithm runs out of space, it stops without completing the filling (and return -1 to indicate failure). Otherwise, the method returns the max number of bytes used on the stack during the filling.

Note
During the algorithm, new_color is treated the same as border_color and will also block the filling procedure when encountered.
Template Parameters
STACK_SIZEsize allocated on the stack (in bytes).
Parameters
start_posStart position.
border_colorborder color that delimits the connected component to fill.
new_colorNew color to use.
Returns
return the max stack used (in bytes) during the algorithm. Return -1 if we run out of memory (in this case the method returns early without completing the full filling.

◆ drawFastVLine()

template<typename color_t >
void tgx::Image< color_t >::drawFastVLine ( iVec2  pos,
int  h,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw an vertical segment of h pixels starting at pos.

Parameters
posposition of the top endpoint of the segment.
hnumber of pixels in the segment.
colorcolor to use.
opacityopacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwritting.

◆ drawFastHLine()

template<typename color_t >
void tgx::Image< color_t >::drawFastHLine ( iVec2  pos,
int  w,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw an horizontal segment of w pixels starting at pos.

Parameters
posposition of the left endpoint of the segment.
wnumber of pixels in the segment.
colorcolor to use.
opacityopacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwritting.

◆ drawLine()

template<typename color_t >
void tgx::Image< color_t >::drawLine ( iVec2  P1,
iVec2  P2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a line segment between two points (uses Bresenham's algorithm).

Parameters
P1The first point.
P2The second point.
colorcolor to use.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwritting.

◆ drawSegment()

template<typename color_t >
void tgx::Image< color_t >::drawSegment ( iVec2  P1,
bool  drawP1,
iVec2  P2,
bool  drawP2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a line segment between two points (using Bresenham's algorithm).

Same as drawLine() but specify also which endpoints should be drawn.

Parameters
P1The first point.
drawP1True to draw the pixel at endpoint P1.
P2The second point.
drawP2True to draw the pixel at endpoint P2.
colorcolor to use.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwritting.

◆ drawLineAA()

template<typename color_t >
void tgx::Image< color_t >::drawLineAA ( fVec2  P1,
fVec2  P2,
color_t  color,
float  opacity = 1.0f 
)

Draw a line segment between two points [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1The first point.
P2The second point.
colorcolor to use.
opacityopacity multiplier between 0.0f and 1.0f (default).

◆ drawThickLineAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickLineAA ( fVec2  P1,
fVec2  P2,
float  line_width,
EndPath  end_P1,
EndPath  end_P2,
color_t  color,
float  opacity = 1.0f 
)

Draw a thick line segment between two points [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Attention
this method superseeds the old drawWideLine() method.
Parameters
P1The first point.
P2The second point.
line_widthWidth of the line.
end_P1specify how the line extremity at P1 should be drawn (c.f. tgx::EndPath)
end_P2specify how the line extremity at P2 should be drawn (c.f. tgx::EndPath)
colorcolor to use.
opacity(Optional) opacity multiplier between 0.0f and 1.0f (default).

◆ drawWedgeLineAA()

template<typename color_t >
void tgx::Image< color_t >::drawWedgeLineAA ( fVec2  P1,
fVec2  P2,
float  line_width_P1,
EndPath  end_P1,
float  line_width_P2,
EndPath  end_P2,
color_t  color,
float  opacity = 1.0f 
)

Draw a from P1 to P2 with with respective wideness line_width_P1 and line_width_P2 at both ends [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1first end point.
P2second end point.
line_width_P1Width of the wedge at P1.
end_P1specify how the line extremity at P1 should be drawn (c.f. tgx::EndPath)
line_width_P2Width of the wedge at P2.
end_P2specify how the line extremity at P2 should be drawn (c.f. tgx::EndPath)
colorcolor to use.
opacity(Optional) opacity multiplier between 0.0f and 1.0f (default).

◆ drawRect()

template<typename color_t >
void tgx::Image< color_t >::drawRect ( const iBox2 B,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a rectangle.

Parameters
BBox that delimits the rectangle to draw.
colorrectangle outline color.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f] or negative to disable blending.

◆ drawThickRect()

template<typename color_t >
void tgx::Image< color_t >::drawThickRect ( const iBox2 B,
int  thickness,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a rectangle with a thick outline.

Parameters
BBox that delimits the rectangle to draw.
thicknessthickness of the border (going 'inside' the rectangle)
colorrectangle outline color.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f] or negative to disable blending.

◆ fillRect()

template<typename color_t >
void tgx::Image< color_t >::fillRect ( const iBox2 B,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled rectangle.

Parameters
Bbox that delimits the rectangle to draw.
colorrectangle color.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillThickRect()

template<typename color_t >
void tgx::Image< color_t >::fillThickRect ( const iBox2 B,
int  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled rectangle with a thick border of a possibly different color.

Parameters
Bbox that delimits the rectangle to draw.
thicknessthickness of the border (going 'inside the rectangle)
color_interiorcolor for the rectangle interior.
color_bordercolor for the rectangle border.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillRectHGradient()

template<typename color_t >
void tgx::Image< color_t >::fillRectHGradient ( iBox2  B,
color_t  color_left,
color_t  color_right,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a rectangle filled with an horizontal gradient of colors.

Parameters
Bbox that delimits the rectangle to draw.
color_leftcolor on the left side.
color_rightcolor on the right side.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillRectVGradient()

template<typename color_t >
void tgx::Image< color_t >::fillRectVGradient ( iBox2  B,
color_t  color_top,
color_t  color_bottom,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a rectangle filled with a vertical gradient of colors.

Parameters
Bbox that delimits the rectangle to draw.
color_topcolor on the top side.
color_bottomcolor on the bottom side.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ drawThickRectAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickRectAA ( const fBox2 B,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled rectangle with a thick border [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
This is probably not the method you want to use: if you just want to draw a nice rectangle with a thick border, try drawThickRect() instead.
Parameters
BBox representing the outer boundary of the rectangle.
thicknessthickness of the boundary (going 'inside' the rectangle)
colorcolor to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillRectAA()

template<typename color_t >
void tgx::Image< color_t >::fillRectAA ( const fBox2 B,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled rectangle [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
This is probably not the method you want to use: if you just want to draw a nice filled rectangle, try fillRect() instead.
Parameters
BBox representing the rectngle to daw.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickRectAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickRectAA ( const fBox2 B,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled rectangle with a thick border of a different color [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
This is probably not the method you want to use: if you just want to draw a nice filled rectangle with a thick border, try fillThickRect() instead.
Parameters
BBox representing the outer boundary of the rectangle
thicknessthickness of the boundary (going 'inside' the rectangle)
color_interiorcolor for the interior
color_bordercolor for the boundary
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawRoundRect()

template<typename color_t >
void tgx::Image< color_t >::drawRoundRect ( const iBox2 B,
int  corner_radius,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a rounded rectangle in box B with radius corner_radius.

Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
colorrectangle color.
opacity(Optional) opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillRoundRect()

template<typename color_t >
void tgx::Image< color_t >::fillRoundRect ( const iBox2 B,
int  corner_radius,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled rounded rectangle in box B with radius corner_radius.

Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
colorrectangle color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ drawRoundRectAA()

template<typename color_t >
void tgx::Image< color_t >::drawRoundRectAA ( const fBox2 B,
float  corner_radius,
color_t  color,
float  opacity = 1.0f 
)

Draw a rounded rectangle [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickRoundRectAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickRoundRectAA ( const fBox2 B,
float  corner_radius,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a rounded rectangle with a thick border [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
thicknessthickness going 'inside' the rounded rectangle (should be >1)
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillRoundRectAA()

template<typename color_t >
void tgx::Image< color_t >::fillRoundRectAA ( const fBox2 B,
float  corner_radius,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled rounded rectangle [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickRoundRectAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickRoundRectAA ( const fBox2 B,
float  corner_radius,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled rounded rectangle with a thick border of another color [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
Bbox that delimits the rectangle to draw.
corner_radiuscorner radius.
thicknessthickness going 'inside' the rounded rectangle (should be >1)
color_interiorcolor.
color_borderThe color border.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawTriangle()

template<typename color_t >
void tgx::Image< color_t >::drawTriangle ( const iVec2 P1,
const iVec2 P2,
const iVec2 P3,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a triangle.

Parameters
P1first vertex.
P2second vertex.
P3third vertex.
colorThe color to use.
opacityOpacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillTriangle()

template<typename color_t >
void tgx::Image< color_t >::fillTriangle ( const iVec2 P1,
const iVec2 P2,
const iVec2 P3,
color_t  interior_color,
color_t  outline_color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled triangle with different colors for the outline and the interior.

Parameters
P1first vertex.
P2second vertex.
P3third vertex.
interior_colorcolor for the interior.
outline_colorcolor for the outline.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawTriangleAA()

template<typename color_t >
void tgx::Image< color_t >::drawTriangleAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
color_t  color,
float  opacity = 1.0f 
)

Draw a triangle [High quality].

Parameters
P1first vertex.
P2second vertex.
P3third vertex.
colorThe color.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickTriangleAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickTriangleAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a triangle with a thick border [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
thicknessThe thickness (going 'inside' the triangle).
colorThe color.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillTriangleAA()

template<typename color_t >
void tgx::Image< color_t >::fillTriangleAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled triangle [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
colorThe color.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickTriangleAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickTriangleAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled triangle with a thick border of a different color [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
thicknessthickness of the border (going 'inside' the triangle).
color_interiorinterior color.
color_borderboundary color.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawGradientTriangle()

template<typename color_t >
template<typename color_alt >
void tgx::Image< color_t >::drawGradientTriangle ( fVec2  P1,
fVec2  P2,
fVec2  P3,
color_alt  colorP1,
color_alt  colorP2,
color_alt  colorP3,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a triangle with gradient color specified by the colors on its vertices.

Parameters
P1First triangle vertex.
P2Second triangle vertex.
P3Third triangle vertex.
colorP1color at the first vertex.
colorP2color at the second vertex.
colorP3color at the third vertex.
opacityOpacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawTexturedTriangle() [1/2]

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedTriangle ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw textured triangle onto the image.

The texture is mapped onto the triangle using bilinear filtering.

Warning
For particular orientations of triangles, access to texture pixels is highly non-linear. For texture stored in slow memory (e.g. flash), this can cause huge slowdown because the read cache becomes basically useless. To overcome this problem:
  1. Move the texture to a faster memory location before drawing.
  2. Or tessellate the triangle into smaller triangles so that the memory data for each triangle fit into the cache.
Parameters
src_imthe image texture to map onto the triangle.
srcP1coords of point 1 on the texture.
srcP2coords of point 2 on the texture.
srcP3coords of point 3 on the texture.
dstP1coords of point 1 on this image.
dstP2coords of point 2 on this image.
dstP3coords of point 3 on this image.
opacityOpacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawTexturedTriangle() [2/2]

template<typename color_t >
template<typename color_t_tex , typename BLEND_OPERATOR >
void tgx::Image< color_t >::drawTexturedTriangle ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
const BLEND_OPERATOR &  blend_op 
)

Blend a textured triangle onto the image.

The texture is mapped onto the triangle using bilinear filtering.

The method takes as input a user defined 'blending operator' with allow to create fancy effects. The blending operator 'blend_op' can be a function/functor/lambda. It takes as input the color of the source (sprite) pixel and the color of the destination pixel and returns the blended color. It must have a signature compatible with

               color_t blend_op(color_t_src src, color_t dst)

(the method can, in fact, return a color of any type but returning type color_t will improve performance).

Warning
For particular orientations of triangles, access to texture pixels is highly non-linear. For texture stored in slow memory (e.g. flash), this can cause huge slowdown because the read cache becomes basically useless. To overcome this problem:
  1. Move the texture to a faster memory location before drawing.
  2. Or tessellate the triangle into smaller triangles so that the memory data for each triangle fit into the cache.
Parameters
src_imthe image texture to map onto the triangle.
srcP1coords of point 1 on the texture.
srcP2coords of point 2 on the texture.
srcP3coords of point 3 on the texture.
dstP1coords of point 1 on this image.
dstP2coords of point 2 on this image.
dstP3coords of point 3 on this image.
blend_opthe blending operator

◆ drawTexturedGradientTriangle()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedGradientTriangle ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
color_t_tex  C1,
color_t_tex  C2,
color_t_tex  C3,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Blend textured triangle on the image while combining it with a color gradient.

The texture is mapped onto the triangle using bilinear filtering.

Warning
For particular orientations of triangles, access to texture pixels is highly non-linear. For texture stored in slow memory (e.g. flash), this can cause huge slowdown because the read cache becomes basically useless. To overcome this problem:
  1. Move the texture to a faster memory location before drawing.
  2. Or tessellate the triangle into smaller triangles so that the memory data for each triangle fit into the cache.
Parameters
src_imthe image/texture to map onto the triangle.
srcP1coords of point 1 on the texture.
srcP2coords of point 2 on the texture.
srcP3coords of point 3 on the texture.
dstP1coords of point 1 on this image.
dstP2coords of point 2 on this image.
dstP3coords of point 3 on this image.
C1color gradient multiplier at point 1.
C2color gradient multiplier at point 2.
C3color gradient multiplier at point 3.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawTexturedMaskedTriangle()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedMaskedTriangle ( const Image< color_t_tex > &  src_im,
color_t_tex  transparent_color,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
float  opacity = 1.0f 
)

Blend textured triangle with a transparency mask (ie a specific color is treated as fully transparent)

Warning
For particular orientations of triangles, access to texture pixels is highly non-linear. For texture stored in slow memory (e.g. flash), this can cause huge slowdown because the read cache becomes basically useless. To overcome this problem:
  1. Move the texture to a faster memory location before drawing.
  2. Or tessellate the triangle into smaller triangles so that the memory data for each triangle fit into the cache.
Parameters
src_imthe image/texture to map onto the triangle.
transparent_colorthe color considered transparent in the source texture.
srcP1coords of point 1 on the texture.
srcP2coords of point 2 on the texture.
srcP3coords of point 3 on the texture.
dstP1coords of point 1 on this image.
dstP2coords of point 2 on this image.
dstP3coords of point 3 on this image.
opacityThe opacity multiplier between 0.0f (transparent) and 1.0f (opaque).

◆ drawTexturedGradientMaskedTriangle()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedGradientMaskedTriangle ( const Image< color_t_tex > &  src_im,
color_t_tex  transparent_color,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
color_t_tex  C1,
color_t_tex  C2,
color_t_tex  C3,
float  opacity = 1.0f 
)

Blend textured triangle with a transparency mask (ie a specific color is treated as fully transparent) and blend it with a color gradient...

Ok, this one is really overkill :p

Warning
For particular orientations of triangles, access to texture pixels is highly non-linear. For texture stored in slow memory (e.g. flash), this can cause huge slowdown because the read cache becomes basically useless. To overcome this problem:
  1. Move the texture to a faster memory location before drawing.
  2. Or tessellate the triangle into smaller triangles so that the memory data for each triangle fit into the cache.
Parameters
src_imthe image/texture to map onto the triangle.
transparent_colorthe color considered transparent in the source texture.
srcP1coords of point 1 on the texture.
srcP2coords of point 2 on the texture.
srcP3coords of point 3 on the texture.
dstP1coords of point 1 on this image.
dstP2coords of point 2 on this image.
dstP3coords of point 3 on this image.
C1color gradient multiplier at point 1.
C2color gradient multiplier at point 2.
C3color gradient multiplier at point 3.
opacityThe opacity multiplier between 0.0f (transparent) and 1.0f (opaque).

◆ drawQuad()

template<typename color_t >
void tgx::Image< color_t >::drawQuad ( iVec2  P1,
iVec2  P2,
iVec2  P3,
iVec2  P4,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a quad.

Parameters
P1The first vertex.
P2The second vertex.
P3The third vertex.
P4The fourth vertex.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillQuad()

template<typename color_t >
void tgx::Image< color_t >::fillQuad ( iVec2  P1,
iVec2  P2,
iVec2  P3,
iVec2  P4,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

draw a filled quad.

Warning
The quad must be convex.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
P4fourth vertex.
colorcolor.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawQuadAA()

template<typename color_t >
void tgx::Image< color_t >::drawQuadAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
fVec2  P4,
color_t  color,
float  opacity = 1.0f 
)

Draw a quad [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1The first vertex.
P2The second vertex.
P3The third vertex.
P4The fourth vertex.
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickQuadAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickQuadAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
fVec2  P4,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a quad with a thick border [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1The first vertex.
P2The second vertex.
P3The third vertex.
P4The fourth vertex.
thicknessThe thickness (going 'inside' the quad)
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillQuadAA()

template<typename color_t >
void tgx::Image< color_t >::fillQuadAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
fVec2  P4,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled quad [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
: the quad must be convex.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
P4fourth vertex.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickQuadAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickQuadAA ( fVec2  P1,
fVec2  P2,
fVec2  P3,
fVec2  P4,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled quad with a thick border of a different color [High quality].

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
: the quad must be convex.
Parameters
P1first vertex.
P2second vertex.
P3third vertex.
P4fourth vertex.
thicknessThe thickness (going 'inside' the quad)
color_interiorinterior color.
color_borderboundary color.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawGradientQuad()

template<typename color_t >
template<typename color_alt >
void tgx::Image< color_t >::drawGradientQuad ( fVec2  P1,
fVec2  P2,
fVec2  P3,
fVec2  P4,
color_alt  colorP1,
color_alt  colorP2,
color_alt  colorP3,
color_alt  colorP4,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a quad with a gradient color specified by the color at the four vertices.

See drawGradientTriangle() for details.

◆ drawTexturedQuad() [1/2]

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedQuad ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  srcP4,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
fVec2  dstP4,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a textured quad using bilinear filtering.

See drawTexturedTriangle() for details.

◆ drawTexturedQuad() [2/2]

template<typename color_t >
template<typename color_t_tex , typename BLEND_OPERATOR >
void tgx::Image< color_t >::drawTexturedQuad ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  srcP4,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
fVec2  dstP4,
const BLEND_OPERATOR &  blend_op 
)

Draw a textured quad with bilinear filtering and a custom blending operator.

See drawTexturedTriangle() for more details.

◆ drawTexturedGradientQuad()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedGradientQuad ( const Image< color_t_tex > &  src_im,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  srcP4,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
fVec2  dstP4,
color_t_tex  C1,
color_t_tex  C2,
color_t_tex  C3,
color_t_tex  C4,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a textured quad using bilinear filtering combined with a color gradient.

See drawTexturedGradientTriangle() for details.

◆ drawTexturedMaskedQuad()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedMaskedQuad ( const Image< color_t_tex > &  src_im,
color_t_tex  transparent_color,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  srcP4,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
fVec2  dstP4,
float  opacity = 1.0f 
)

Draw a textured quad using bilinear filtering and with a mask (ie a fixed transparent color).

See drawTexturedMaskedTriangle() for details.

◆ drawTexturedGradientMaskedQuad()

template<typename color_t >
template<typename color_t_tex >
void tgx::Image< color_t >::drawTexturedGradientMaskedQuad ( const Image< color_t_tex > &  src_im,
color_t_tex  transparent_color,
fVec2  srcP1,
fVec2  srcP2,
fVec2  srcP3,
fVec2  srcP4,
fVec2  dstP1,
fVec2  dstP2,
fVec2  dstP3,
fVec2  dstP4,
color_t_tex  C1,
color_t_tex  C2,
color_t_tex  C3,
color_t_tex  C4,
float  opacity = 1.0f 
)

Draw a textured quad using bilinear filtering and with a mask (ie a fixed transparent color) and combined with a color gradient.

See drawTexturedGradientMaskedTriangle() for details.

◆ drawPolyline() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawPolyline ( int  nbpoints,
const iVec2  tabPoints[],
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn].

Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawPolyline() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawPolyline ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn].

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(iVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point.
Parameters
next_pointcallback functor that provides the list of points.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawPolylineAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawPolylineAA ( int  nbpoints,
const fVec2  tabPoints[],
color_t  color,
float  opacity = 1.0f 
)

Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points.
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawPolylineAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawPolylineAA ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = 1.0f 
)

Draw a polyline ie a sequence of consecutif segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point.
Parameters
next_pointcallback functior that privdes the list of points.
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickPolylineAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawThickPolylineAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
EndPath  end_P0,
EndPath  end_Pn,
color_t  color,
float  opacity = 1.0f 
)

Draw a thick polyline ie a sequence of consecutif thick segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points.
thicknessthickness of the polyline.
end_P0specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_Pnspecify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickPolylineAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawThickPolylineAA ( FUNCTOR_NEXT  next_point,
float  thickness,
EndPath  end_P0,
EndPath  end_Pn,
color_t  color,
float  opacity = 1.0f 
)

Draw a thick polyline ie a sequence of consecutif thick segments [P0,P1] , [P1,P2],,, [Pn-1,Pn] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point.
Parameters
next_pointcallback functior that provides the list of points.
thicknessthickness of the polyline.
end_P0specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_Pnspecify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawPolygon() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawPolygon ( int  nbpoints,
const iVec2  tabPoints[],
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a closed polygon with vertices [P0,P2,,, PN].

Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points of the polygon.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawPolygon() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawPolygon ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a closed polygon with vertices [P0,P2,,, PN].

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(iVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point.
Parameters
next_pointcallback functor that provides the list of points.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillPolygon() [1/2]

template<typename color_t >
void tgx::Image< color_t >::fillPolygon ( int  nbpoints,
const iVec2  tabPoints[],
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled polygon with vertices [P0,P2,,, PN].

Warning
The polygon must be convex (or at least star-shaped from its center of mass).
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points of the polygon.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillPolygon() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::fillPolygon ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled polygon with vertices [P0,P2,,, PN].

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(iVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point AND THEN THE FUNCTOR MUST RESET BACK THE FIRST POINT !
Warning
In order to draw the polygon correctly, all points must be queried TWICE so the callback must reset to the first point after returning false.
The polygon must be convex (or at least star-shaped from its center of mass).
Parameters
next_pointcallback functor that provides the list of points.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawPolygonAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawPolygonAA ( int  nbpoints,
const fVec2  tabPoints[],
color_t  color,
float  opacity = 1.0f 
)

Draw a closed polygon with vertices [P0,P2,,, PN] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points of the polygon.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawPolygonAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawPolygonAA ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = 1.0f 
)

Draw a closed polygon with vertices [P0,P2,,, PN] (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point.
Parameters
next_pointcallback functor that provides the list of points.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickPolygonAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::drawThickPolygonAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a polygon with thick lines (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points that delimit the polygon outer boundary.
thicknessThe thickness of the polygon boundary (going inside the polygon).
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickPolygonAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::drawThickPolygonAA ( FUNCTOR_NEXT  next_point,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a polygon with thick lines (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point AND THEN THE FUNCTOR MUST RESET BACK THE FIRST POINT !
Warning
In order to draw the polygon correctly, all points must be queried TWICE so the callback must reset to the first point after returning false.
Parameters
next_pointcallback functor that provides the list of points delimiting the outer boundary of the polygon.
thicknessThe thickness of the polygon boundary (going inside the polygon).
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillPolygonAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::fillPolygonAA ( int  nbpoints,
const fVec2  tabPoints[],
color_t  color,
float  opacity = 1.0f 
)

Draw a filled polygon (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Warning
The polygon must be convex (or at least star-shaped from its center of mass).
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points of the polygon.
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillPolygonAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::fillPolygonAA ( FUNCTOR_NEXT  next_point,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled polygon (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point AND THEN THE FUNCTOR MUST RESET BACK THE FIRST POINT !
Warning
In order to draw the polygon correctly, all points must be queried TWICE so the callback must reset to the first point after returning false.
The polygon must be convex (or at least star-shaped from its center of mass).
Parameters
next_pointcallback functor that provides the list of points delimiting the polygon.
colorThe color to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickPolygonAA() [1/2]

template<typename color_t >
void tgx::Image< color_t >::fillThickPolygonAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
color_t  interior_color,
color_t  border_color,
float  opacity = 1.0f 
)

Draw a filled polygon with a thick border of a different color (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
nbpointsnumber of points in tabPoints.
tabPointsarray of points of the polygon
thicknessThe thickness of the polygon boundary (going 'inside' the polygon).
interior_colorcolor for the interior
border_colorcolor for the thick boundary
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickPolygonAA() [2/2]

template<typename color_t >
template<typename FUNCTOR_NEXT >
void tgx::Image< color_t >::fillThickPolygonAA ( FUNCTOR_NEXT  next_point,
float  thickness,
color_t  interior_color,
color_t  border_color,
float  opacity = 1.0f 
)

Draw a filled polygon with a thick border of a different color (High quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:

bool next_point(fVec2 & P)

The callback must store the next point in the reference P and return:

  • true: if there are additional points to plot after this one.
  • false: if this is the last point AND THEN THE FUNCTOR MUST RESET BACK THE FIRST POINT !
Warning
In order to draw the polygon correctly, all points must be queried TWICE so the callback must reset to the first point after returning false.
The polygon must be convex (or at least star-shaped from its center of mass).
Parameters
next_pointcallback functor that provides the list of points delimiting the polygon outer boundary.
thicknessThe thickness of the polygon boundary (going 'inside' the polygon)
interior_colorcolor for the interior
border_colorcolor for the thick boundary
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawCircle()

template<typename color_t >
void tgx::Image< color_t >::drawCircle ( iVec2  center,
int  r,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a circle.

Parameters
centerCircle center.
rradius.
colorcolor.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillCircle()

template<typename color_t >
void tgx::Image< color_t >::fillCircle ( iVec2  center,
int  r,
color_t  interior_color,
color_t  outline_color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled circle with different colors for outline and interior.

Parameters
centerCircle center.
rradius.
interior_colorcolor for the interior.
outline_colorcolor for the outline.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ drawCircleAA()

template<typename color_t >
void tgx::Image< color_t >::drawCircleAA ( fVec2  center,
float  r,
color_t  color,
float  opacity = 1.0f 
)

Draw a circle (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerCircle center.
rradius.
colorcolor
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickCircleAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickCircleAA ( fVec2  center,
float  r,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a circle with a thick border (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerCircle center.
rexternal radius (the internal radius is r - thickness).
thicknessthickness (going inside the circle).
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillCircleAA()

template<typename color_t >
void tgx::Image< color_t >::fillCircleAA ( fVec2  center,
float  r,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled circle (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerCircle center.
rradius.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickCircleAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickCircleAA ( fVec2  center,
float  r,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled circle with a thick border of a different color (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerCircle center.
rexternal radius (the internal radius is r - thickness).
thicknessthickness 'going inside the circle'
color_interiorcolor of the interior
color_bordercolor of the boundary
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawCircleArcAA()

template<typename color_t >
void tgx::Image< color_t >::drawCircleArcAA ( fVec2  center,
float  r,
float  angle_start,
float  angle_end,
color_t  color,
float  opacity = 1.0f 
)

Draw a circle arc (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

the arc is drawn moving clockwise from angle_start until reaching angle_end.

angle (in degrees) position
0 12AM
90 3AM
180 6AM
270 9AM
Parameters
centercircle center position.
rcircle radius.
angle_startangle in degrees of the begigining of the arc.
angle_endangle in degrees of the end of the arc.
colorcolor to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickCircleArcAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickCircleArcAA ( fVec2  center,
float  r,
float  angle_start,
float  angle_end,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw a circle arc with a thick border (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

the arc is drawn moving clockwise from angle_start until reaching angle_end.

angle (in degrees) position
0 12AM
90 3AM
180 6AM
270 9AM
Parameters
centercircle center position.
rcircle radius.
angle_startangle in degrees of the begigining of the arc.
angle_endangle in degrees of the end of the arc.
thicknessThe thickness of the arc, going 'inside' the circle.
colorcolor to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillCircleSectorAA()

template<typename color_t >
void tgx::Image< color_t >::fillCircleSectorAA ( fVec2  center,
float  r,
float  angle_start,
float  angle_end,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled circle sector/slice/pie (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

the arc is drawn moving clockwise from angle_start until reaching angle_end.

angle (in degrees) position
0 12AM
90 3AM
180 6AM
270 9AM
Parameters
centercircle center position.
rcircle radius.
angle_startangle in degrees of the begigining of the arc.
angle_endangle in degrees of the end of the arc.
colorcolor to use.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickCircleSectorAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickCircleSectorAA ( fVec2  center,
float  r,
float  angle_start,
float  angle_end,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled circle sector/slice/pie with a thick border of a different color (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

the arc is drawn moving clockwise from angle_start until reaching angle_end.

angle (in degrees) position
0 12AM
90 3AM
180 6AM
270 9AM
Parameters
centercircle center position.
rcircle radius.
angle_startangle in degrees of the begigining of the arc.
angle_endangle in degrees of the end of the arc.
thicknessborder thickness going 'inside' the circle.
color_interiorcolor for the interior.
color_bordercolor for the boundary.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawEllipse()

template<typename color_t >
void tgx::Image< color_t >::drawEllipse ( iVec2  center,
iVec2  radiuses,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw an ellipse.

Parameters
centerCircle center.
radiusesradiuses along the x and y axis.
colorcolor.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ fillEllipse()

template<typename color_t >
void tgx::Image< color_t >::fillEllipse ( iVec2  center,
iVec2  radiuses,
color_t  interior_color,
color_t  outline_color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a filled ellipse with different colors for the outline and the interior.

Parameters
centerCircle center.
radiusesradiuses along the x and y axis.
interior_colorcolor for the interior.
outline_colorcolor for the outline.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending.

◆ drawEllipseAA()

template<typename color_t >
void tgx::Image< color_t >::drawEllipseAA ( fVec2  center,
fVec2  radiuses,
color_t  color,
float  opacity = 1.0f 
)

Draw an ellipse (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerEllipse center.
radiusesradiuses along the x and y axis.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawThickEllipseAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickEllipseAA ( fVec2  center,
fVec2  radiuses,
float  thickness,
color_t  color,
float  opacity = 1.0f 
)

Draw an ellipse with a thick border (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerEllipse center.
radiusesexternal radiuses along the x and y axis.
thicknessthickness going 'inside' the ellipse
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillEllipseAA()

template<typename color_t >
void tgx::Image< color_t >::fillEllipseAA ( fVec2  center,
fVec2  radiuses,
color_t  color,
float  opacity = 1.0f 
)

Draw a filled ellipse (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerEllipse center.
radiusesradiuses along the x and y axis.
colorcolor.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ fillThickEllipseAA()

template<typename color_t >
void tgx::Image< color_t >::fillThickEllipseAA ( fVec2  center,
fVec2  radiuses,
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = 1.0f 
)

Draw a filled ellipse with a thick border of a different color (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
centerellipse center.
radiusesradiuses along the x and y axis.
thicknessborder thickness going 'inside' the ellipse
color_interiorcolor of the interior.
color_bordercolor of the boundary.
opacity(Optional) Opacity multiplier in [0.0f, 1.0f].

◆ drawQuadBezier()

template<typename color_t >
void tgx::Image< color_t >::drawQuadBezier ( iVec2  P1,
iVec2  P2,
iVec2  PC,
float  wc,
bool  drawP2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a quadratic (rational) Bezier curve.

Parameters
P1Start point.
P2End point.
PCControl point.
wcControl point weight (must be > 0). Fastest for wc=1.
drawP2true to draw the endpoint P2.
colorThe color to use.
opacityOpacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawCubicBezier()

template<typename color_t >
void tgx::Image< color_t >::drawCubicBezier ( iVec2  P1,
iVec2  P2,
iVec2  PA,
iVec2  PB,
bool  drawP2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a cubic Bezier curve.

Parameters
P1Start point.
P2End point.
PAfirst control point.
PBsecond control point.
drawP2true to draw the endpoint P2.
colorThe color to use.
opacityOpacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawQuadSpline()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawQuadSpline ( int  nbpoints,
const iVec2  tabPoints[],
bool  draw_last_point,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a quadratic spline interpolating between a given set of points.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
draw_last_pointtrue to draw the last point.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawCubicSpline()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawCubicSpline ( int  nbpoints,
const iVec2  tabPoints[],
bool  draw_last_point,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a cubic spline interpolating between a given set of points.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
draw_last_pointtrue to draw the last point.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawClosedSpline()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawClosedSpline ( int  nbpoints,
const iVec2  tabPoints[],
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a closed quadratic spline interpolating between a given set of points.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickQuadBezierAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickQuadBezierAA ( fVec2  P1,
fVec2  P2,
fVec2  PC,
float  wc,
float  thickness,
EndPath  end_P1,
EndPath  end_P2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a thick quadratic (rational) Bezier curve (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1Start point.
P2End point.
PCControl point.
wcControl point weight (must be >0).
thicknessthickness of the curve.
end_P1specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_P2specify how the extremity P2 should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickCubicBezierAA()

template<typename color_t >
void tgx::Image< color_t >::drawThickCubicBezierAA ( fVec2  P1,
fVec2  P2,
fVec2  PA,
fVec2  PB,
float  thickness,
EndPath  end_P1,
EndPath  end_P2,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a thick cubic Bezier curve (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.
Parameters
P1Start point.
P2End point.
PAfirst control point.
PBsecond control point.
thicknessthickness of the curve.
end_P1specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_P2specify how the extremity P2 should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickQuadSplineAA()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawThickQuadSplineAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
EndPath  end_P0,
EndPath  end_Pn,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a thick quadratic spline interpolating between a given set of points (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
thicknessthickness of the curve.
end_P0specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_Pnspecify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickCubicSplineAA()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawThickCubicSplineAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
EndPath  end_P0,
EndPath  end_Pn,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a thick cubic spline interpolating between a given set of points (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
thicknessthickness of the curve.
end_P0specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
end_Pnspecify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ drawThickClosedSplineAA()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::drawThickClosedSplineAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a thick closed quadratic spline interpolating between a given set of points (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
thicknessthickness of the curve.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillClosedSplineAA()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::fillClosedSplineAA ( int  nbpoints,
const fVec2  tabPoints[],
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Fill a region delimited by a closed quadratic spline (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Warning
The region should be convex (or at least star-shape around center of mass). Even for a convex region, the drawing may not be perfect if there are sharp turns.
Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
colorThe color to use.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fillThickClosedSplineAA()

template<typename color_t >
template<int SPLINE_MAX_POINTS = 32>
void tgx::Image< color_t >::fillThickClosedSplineAA ( int  nbpoints,
const fVec2  tabPoints[],
float  thickness,
color_t  color_interior,
color_t  color_border,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Fill a region delimited by a closed thick quadratic spline where the interior and boundary can have different colors (high quality).

Note
High quality drawing with anti-aliasing and sub-pixel precision.

The template parameter SPLINE_MAX_POINTS defines the maximum number of points that a spline can have. Can be increased if needed (but increase memory allocated on stack when the method is called).

Warning
  1. The region should be convex (or at least star-shape around center of mass). Even for a convex region, the drawing may not be perfect if there are sharp turns.
  2. If the shape is 'very irregular'. it might be better to draw a thick curve with drawThickClosedSplineAA() and with thickness (at least 3) and then use the fill() method to color the interior.
Template Parameters
SPLINE_MAX_POINTSMax number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)
Parameters
nbpointsnumber of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
tabPointsthe array of points to interpolate.
thicknessthickness of the curve.
color_interiorThe color to use.
color_borderThe color border.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.

◆ fontHeight() [1/2]

template<typename color_t >
int tgx::Image< color_t >::fontHeight ( const GFXfont font) const

Query the height of a font.

overload for GFXfont.

Remarks
this method simply forwards the calls tgx::fontHeight(const GFXfont & font).
Parameters
fontThe font.
Returns
the number of vertical pixels between two lines of text with this font.

◆ fontHeight() [2/2]

template<typename color_t >
int tgx::Image< color_t >::fontHeight ( const ILI9341_t3_font_t font) const

Query the height of a font.

overload for ILI9341_t3_font_t.

Remarks
this method simply forwards the calls tgx::fontHeight(const ILI9341_t3_font_t& font).
Parameters
fontThe font.
Returns
the number of vertical pixels between two lines of text with this font.

◆ measureChar() [1/2]

template<typename color_t >
iBox2 tgx::Image< color_t >::measureChar ( char  c,
iVec2  pos,
const GFXfont font,
Anchor  anchor = DEFAULT_TEXT_ANCHOR,
int *  xadvance = nullptr 
) const

Compute the bounding box of a character.

overload for ILI9341_t3_font_t.

Remarks
this method simply forwards the calls tgx::measureChar(char c, iVec2 pos, const GFXfont& font, Anchor anchor, int* xadvance).
Parameters
cThe character.
posposition of the anchor point in this image.
fontThe font to use.
anchor(Optional) location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
[in,out]xadvanceIf non-null, the number of pixel to advance horizontally after drawing the char is stored here.
Returns
the bounding box of pixels occupied by the char draw with fontwhen its chosen anchor is at pos.

◆ measureChar() [2/2]

template<typename color_t >
iBox2 tgx::Image< color_t >::measureChar ( char  c,
iVec2  pos,
const ILI9341_t3_font_t font,
Anchor  anchor = DEFAULT_TEXT_ANCHOR,
int *  xadvance = nullptr 
) const

Compute the bounding box of a character.

overload for ILI9341_t3_font_t.

Remarks
this method simply forwards the calls tgx::measureChar(char c, iVec2 pos, const ILI9341_t3_font_t& font, Anchor anchor, int* xadvance).
Parameters
cThe character.
posposition of the anchor point in this image.
fontThe font to use.
anchor(Optional) location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
[in,out]xadvanceIf non-null, the number of pixel to advance horizontally after drawing the char is stored here.
Returns
the bounding box of pixels occupied by the char draw with fontwhen its chosen anchor is at pos.

◆ measureText() [1/2]

template<typename color_t >
iBox2 tgx::Image< color_t >::measureText ( const char *  text,
iVec2  pos,
const GFXfont font,
Anchor  anchor = DEFAULT_TEXT_ANCHOR,
bool  wrap_text = false,
bool  start_newline_at_0 = false 
) const

Compute the bounding box of a text.

overload for GFXfont.

Parameters
textThe text.
posposition of the anchor point in the image.
fontThe font to use.
anchor(Optional) location of the anchor with respect to the text bounding box. (by default, this is the BASELINE|LEFT).
wrap_text(Optional) True to wrap wrap text at the end of image.
start_newline_at_0(Optional) True to start a new line of text at x=0 and false to start at x=pos.x.
Returns
the bounding box of pixels occupied by the text draw with font when its chosen anchor is at pos.

◆ measureText() [2/2]

template<typename color_t >
iBox2 tgx::Image< color_t >::measureText ( const char *  text,
iVec2  pos,
const ILI9341_t3_font_t font,
Anchor  anchor = DEFAULT_TEXT_ANCHOR,
bool  wrap_text = false,
bool  start_newline_at_0 = false 
) const

Compute the bounding box of a text.

overload for ILI9341_t3_font_t.

Parameters
textThe text.
posposition of the anchor point in the image.
fontThe font to use.
anchor(Optional) location of the anchor with respect to the text bounding box. (by default, this is the BASELINE|LEFT).
wrap_text(Optional) True to wrap wrap text at the end of image.
start_newline_at_0(Optional) True to start a new line of text at x=0 and false to start at x=pos.x.
Returns
the bounding box of pixels occupied by the text draw with font when its chosen anchor is at pos.

◆ drawChar() [1/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawChar ( char  c,
iVec2  pos,
const GFXfont font,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a single character at position pos on the image and return the position for the next character.

overload for GFXfont.

Parameters
cThe character to draw.
posLocation of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
fontThe font to use.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to draw the next char.

◆ drawChar() [2/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawChar ( char  c,
iVec2  pos,
const ILI9341_t3_font_t font,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a single character at position pos on the image and return the position for the next character.

overload for ILI9341_t3_font_t.

Parameters
cThe character to draw.
posLocation of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
fontThe font to use.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to draw the next char.

◆ drawText() [1/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawText ( const char *  text,
iVec2  pos,
const GFXfont font,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a text at a given position with a given font.

overload for GFXFont.

Note
use char '\n' to changes line.
Parameters
textThe text to draw.
posLocation of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
fontThe font to use.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to use draw the next char after the text.

◆ drawText() [2/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawText ( const char *  text,
iVec2  pos,
const ILI9341_t3_font_t font,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Draw a text at a given position with a given font.

overload for ILI9341_t3_font_t.

Note
use char '\n' to changes line.
Parameters
textThe text to draw.
posLocation of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
fontThe font to use.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to use draw the next char after the text.

◆ drawTextEx() [1/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawTextEx ( const char *  text,
iVec2  pos,
Anchor  anchor,
const GFXfont font,
bool  wrap_text,
bool  start_newline_at_0,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Advanced drawText method.

Draw a text with a given font at a given position relative to a given anchor point.

overload for GFXFont.

Note
Use char '\n' to changes line.
Parameters
textThe text to draw.
posposition to draw the text. This is the position to which will be mapped the selected anchor point of the text.
anchorSelect the anchor point of the text c.f. enum tgx::Anchor (the drawText() methods uses BASELINE|LEFT).
fontThe font to use.
wrap_textTrue to wrap wrap text at the end of image. Wrapping occur per character (not per word).
start_newline_at_0True to start a new line of text at position x=0 and false to start at x=pos.x.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to draw the next char (when using the same anchor location).

◆ drawTextEx() [2/2]

template<typename color_t >
iVec2 tgx::Image< color_t >::drawTextEx ( const char *  text,
iVec2  pos,
Anchor  anchor,
const ILI9341_t3_font_t font,
bool  wrap_text,
bool  start_newline_at_0,
color_t  color,
float  opacity = TGX_DEFAULT_NO_BLENDING 
)

Advanced drawText method.

Draw a text with a given font at a given position relative to a given anchor point.

overload for ILI9341_t3_font_t.

Note
Use char '\n' to changes line.
Parameters
textThe text to draw.
posposition to draw the text. This is the position to which will be mapped the selected anchor point of the text.
anchorSelect the anchor point of the text c.f. enum tgx::Anchor (the drawText() methods uses BASELINE|LEFT).
fontThe font to use.
wrap_textTrue to wrap wrap text at the end of image. Wrapping occur per character (not per word).
start_newline_at_0True to start a new line of text at position x=0 and false to start at x=pos.x.
colorThe color.
opacity(Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending and simply use overwrite.
Returns
the position to draw the next char (when using the same anchor location).

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