| TGX 1.0.7 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Static Public Attributes | List of all members
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 The image object does not manage the buffer memory: memory allocation/deallocation is the user's respnsability. 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...
Image & | operator= (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 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). 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 These method use sub-pixel precision (but not anti-aliasing). 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 These method use sub-pixel precision (but not anti-aliasing). 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: AdafruitGFX (https://glenviewsoftware.com/projects/products/adafonteditor/adafruit-gfx-font-format) ILI9341_t3 v1 (https://forum.pjrc.com/threads/54316-ILI9341_t-font-structure-format) ILI9341_t3 v23 (antialiased) (https://github.com/projectitis/packedbdf/blob/master/packedbdf.md) 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, const GFXfont &font, Anchor anchor, 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, const ILI9341_t3_font_t &font, Anchor anchor, bool wrap_text, bool start_newline_at_0, color_t color, float opacity=TGX_DEFAULT_NO_BLENDING)
| Advanced drawText method. More...
Extensions. Interfacing TGX with other libraries.
template<typename T >
void | setOpenFontRender (T &ofr, float opacity=TGX_DEFAULT_NO_BLENDING)
| Link the image with Takkoa's OpenFontRender library : https://github.com/takkaO/OpenFontRender. More...
template<typename PNG_T >
int | PNGDecode (PNG_T &png, iVec2 topleft=iVec2(0, 0), float opacity=1.0f)
| Decode a PNG image into this image using the PNGDec library: https://github.com/bitbank2/PNGdec/. More...
template<typename JPEG_T >
int | JPEGDecode (JPEG_T &jpeg, iVec2 topleft=iVec2(0, 0), int options=0, float opacity=1.0f)
| Decode a JPEG image into this image using the JPEGDEC library: https://github.com/bitbank2/JPEGDEC/. More...
template<typename GIF_T >
int | GIFplayFrame (GIF_T &gif, iVec2 topleft=iVec2(0, 0), float opacity=1.0f)
| Decode a (possibly animated) GIF image into this image using the AnimatedGIF library: https://github.com/bitbank2/AnimatedGIF/. 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_t | Color 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/-]
   tgx::Image::fill
   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

  buffer | the image buffer.
  lx | the image width.
  ly | the 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

  buffer | the image buffer.
  dim | the image dimension (width, height) in pixels.
  stride | the 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

  im | The source image.
  subbox | The 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

  im | The 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

  im | The 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

  buffer | the pixel buffer.
  lx | image width.
  ly | image 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

  buffer | the pixel buffer.
  dim | the 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

  subbox | The 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

  subbox | The 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

  B | box 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_x | left boundary (inclusive)
  max_x | right boundary (inclusive)
  min_y | top boundary (inclusive)
  max_y | bottom 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

  CHECKRANGE | set to false to disable range checking (danger!)

Parameters

  pos | position.
  color | color 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

  CHECKRANGE | set to false to disable range checking (danger!)

Parameters

  pos | position given as a floating point value vector.
  color | color 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

  CHECKRANGE | set to false to disable range checking (danger!)

Parameters

  pos | The position.
  color | The color to blend.
  opacity | opacity 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

  CHECKRANGE | set to false to disable range checking (danger!)

Parameters

  pos | The position given as a floating point value vector.
  color | The color to blend.
  opacity | opacity 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

  CHECKRANGE | If set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!)

Parameters

  pos | The 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

  CHECKRANGE | If set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!)

Parameters

  pos | The 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

  pos | The 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

  pos | The 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

  x | x-coordinate.
  y | y-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

  x | x-coordinate.
  y | y-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; } );
  tgx::RGB565
  Color in R5/G6/B5 format.
  Definition: Color.h:216
  tgx::Vec2
  Generic 2D vector [specializations iVec2, fVec2, dVec2].
  Definition: Vec2.h:64

Parameters

  cb_fun | The 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_fun | The 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_fun | The callback function.
  B | The 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_fun | The callback function.
  B | The 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

  sprite | The sprite image to blit.
  upperleftpos | Position 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" with images of the same color format, use the blit()
     method with an opacity parameter instead of this method as it will be a little faster.

Parameters

  sprite | The sprite image to blend.
  upperleftpos | Position of the upper left corner of the sprite in the image.
  blend_op | The 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

  sprite | The sprite image to blit.
  upperleftpos | Position inside this image of the upper left corner of the sprite (after rotation).
  angle | Clockwise angle to rotate the sprite prior to blitting. In degrees. 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" with images of the same color format, use the blitRotated() method with an opacity parameter instead of this method as it will be a little faster.

Parameters

  sprite | The sprite image to blit.
  upperleftpos | Position inside this image of the upper left corner of the sprite (after rotation).
  angle | Clockwise angle to rotate the sprite prior to blitting. In degrees. Must be either 0, 90, 180 or 270.
  blend_op | The 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

  sprite | The sprite image to blit.
  transparent_color | The sprite color considered transparent.
  upperleftpos | Position 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_sprite | The sprite to save part of this image into.
  | upperleftpos | Position 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 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_SIZE | Size 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_im | The sprite image to draw.
  anchor_src | Position of the anchor point in the sprite image.
  anchor_dst | Position 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 (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_SIZE | Size 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_im | The sprite image to draw.
  anchor_src | Position of the anchor point in the sprite image.
  anchor_dst | Position of the anchor point in this image.
  scale | Scaling factor (1.0f for no rescaling).
  angle_degrees | The rotation angle in degrees (clockwise, default 0 for no rotation).
  blend_op | blending 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 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_SIZE | Size 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_im | The sprite image to draw.
  transparent_color | The sprite color considered transparent.
  anchor_src | Position of the anchor point in the sprite image.
  anchor_dst | Position of the anchor point in this image.
  scale | Scaling factor (default 1.0f for no rescaling).
  angle_degrees | The rotation angle in degrees (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.

## ◆ 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.

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_im | The 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.
  1. To perform "classical alpha blending" with images of the same color format, use the copyFrom() method with an opacity parameter instead of this method as it will be a little faster.

Parameters

  src_im | Source image to copy onto this image.
  blend_op | The 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_image | the 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_dst | Color 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

  color | The 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

  color | The 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_color | color at the top of the image.
  bottom_color | color 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_color | color on the left side of the image.
  right_color | color 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_SIZE | size allocated on the stack (in bytes).

Parameters

  start_pos | Start position. The color to replace is the color at that position.
  new_color | New 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_SIZE | size allocated on the stack (in bytes).

Parameters

  start_pos | Start position.
  border_color | border color that delimits the connected component to fill.
  new_color | New 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

  pos | position of the top endpoint of the segment.
  h | number of pixels in the segment.
  color | color to use.
  opacity | opacity 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

  pos | position of the left endpoint of the segment.
  w | number of pixels in the segment.
  color | color to use.
  opacity | opacity 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

  P1 | The first point.
  P2 | The second point.
  color | color 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

  P1 | The first point.
  drawP1 | True to draw the pixel at endpoint P1.
  P2 | The second point.
  drawP2 | True to draw the pixel at endpoint P2.
  color | color 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

  P1 | The first point.
  P2 | The second point.
  color | color to use.
  opacity | opacity 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

  P1 | The first point.
  P2 | The second point.
  line_width | Width of the line.
  end_P1 | specify how the line extremity at P1 should be drawn (c.f. `tgx::EndPath`)
  end_P2 | specify how the line extremity at P2 should be drawn (c.f. `tgx::EndPath`)
  color | color 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

  P1 | first end point.
  P2 | second end point.
  line_width_P1 | Width of the wedge at P1.
  end_P1 | specify how the line extremity at P1 should be drawn (c.f. `tgx::EndPath`)
  line_width_P2 | Width of the wedge at P2.
  end_P2 | specify how the line extremity at P2 should be drawn (c.f. `tgx::EndPath`)
  color | color 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

  B | Box that delimits the rectangle to draw.
  color | rectangle 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

  B | Box that delimits the rectangle to draw.
  thickness | thickness of the border (going 'inside' the rectangle)
  color | rectangle 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

  B | box that delimits the rectangle to draw.
  color | rectangle 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

  B | box that delimits the rectangle to draw.
  thickness | thickness of the border (going 'inside the rectangle)
  color_interior | color for the rectangle interior.
  color_border | color 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

  B | box that delimits the rectangle to draw.
  color_left | color on the left side.
  color_right | color 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

  B | box that delimits the rectangle to draw.
  color_top | color on the top side.
  color_bottom | color 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

  B | Box representing the outer boundary of the rectangle.
  thickness | thickness of the boundary (going 'inside' the rectangle)
  color | color 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

  B | Box representing the rectngle to daw.
  color | color.
  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

  B | Box representing the outer boundary of the rectangle
  thickness | thickness of the boundary (going 'inside' the rectangle)
  color_interior | color for the interior
  color_border | color 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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  color | rectangle 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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  color | rectangle 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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  color | color.
  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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  thickness | thickness going 'inside' the rounded rectangle (should be >1)
  color | color.
  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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  color | color.
  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

  B | box that delimits the rectangle to draw.
  corner_radius | corner radius.
  thickness | thickness going 'inside' the rounded rectangle (should be >1)
  color_interior | color.
  color_border | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  color | The color to use.
  opacity | Opacity 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  interior_color | color for the interior.
  outline_color | color 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  color | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  thickness | The thickness (going 'inside' the triangle).
  color | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  color | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  thickness | thickness of the border (going 'inside' the triangle).
  color_interior | interior color.
  color_border | boundary 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

  P1 | First triangle vertex.
  P2 | Second triangle vertex.
  P3 | Third triangle vertex.
  colorP1 | color at the first vertex.
  colorP2 | color at the second vertex.
  colorP3 | color at the third vertex.
  opacity | Opacity 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_im | the image texture to map onto the triangle.
  srcP1 | coords of point 1 on the texture.
  srcP2 | coords of point 2 on the texture.
  srcP3 | coords of point 3 on the texture.
  dstP1 | coords of point 1 on this image.
  dstP2 | coords of point 2 on this image.
  dstP3 | coords of point 3 on this image.
  opacity | Opacity 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_im | the image texture to map onto the triangle.
  srcP1 | coords of point 1 on the texture.
  srcP2 | coords of point 2 on the texture.
  srcP3 | coords of point 3 on the texture.
  dstP1 | coords of point 1 on this image.
  dstP2 | coords of point 2 on this image.
  dstP3 | coords of point 3 on this image.
  blend_op | the 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_im | the image/texture to map onto the triangle.
  srcP1 | coords of point 1 on the texture.
  srcP2 | coords of point 2 on the texture.
  srcP3 | coords of point 3 on the texture.
  dstP1 | coords of point 1 on this image.
  dstP2 | coords of point 2 on this image.
  dstP3 | coords of point 3 on this image.
  C1 | color gradient multiplier at point 1.
  C2 | color gradient multiplier at point 2.
  C3 | color 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_im | the image/texture to map onto the triangle.
  transparent_color | the color considered transparent in the source texture.
  srcP1 | coords of point 1 on the texture.
  srcP2 | coords of point 2 on the texture.
  srcP3 | coords of point 3 on the texture.
  dstP1 | coords of point 1 on this image.
  dstP2 | coords of point 2 on this image.
  dstP3 | coords of point 3 on this image.
  opacity | The 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_im | the image/texture to map onto the triangle.
  transparent_color | the color considered transparent in the source texture.
  srcP1 | coords of point 1 on the texture.
  srcP2 | coords of point 2 on the texture.
  srcP3 | coords of point 3 on the texture.
  dstP1 | coords of point 1 on this image.
  dstP2 | coords of point 2 on this image.
  dstP3 | coords of point 3 on this image.
  C1 | color gradient multiplier at point 1.
  C2 | color gradient multiplier at point 2.
  C3 | color gradient multiplier at point 3.
  opacity | The 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

  P1 | The first vertex.
  P2 | The second vertex.
  P3 | The third vertex.
  P4 | The fourth vertex.
  color | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  P4 | fourth vertex.
  color | color.
  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

  P1 | The first vertex.
  P2 | The second vertex.
  P3 | The third vertex.
  P4 | The fourth vertex.
  color | The 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

  P1 | The first vertex.
  P2 | The second vertex.
  P3 | The third vertex.
  P4 | The fourth vertex.
  thickness | The thickness (going 'inside' the quad)
  color | The 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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  P4 | fourth vertex.
  color | color.
  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

  P1 | first vertex.
  P2 | second vertex.
  P3 | third vertex.
  P4 | fourth vertex.
  thickness | The thickness (going 'inside' the quad)
  color_interior | interior color.
  color_border | boundary 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points.
  color | The 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_point | callback functor that provides the list of points.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points.
  color | The 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_point | callback functior that privdes the list of points.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points.
  thickness | thickness of the polyline.
  end_P0 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_Pn | specify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
  color | The 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_point | callback functior that provides the list of points.
  thickness | thickness of the polyline.
  end_P0 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_Pn | specify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points of the polygon.
  color | The 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_point | callback functor that provides the list of points.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points of the polygon.
  color | The 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_point | callback functor that provides the list of points.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points of the polygon.
  color | The 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_point | callback functor that provides the list of points.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points that delimit the polygon outer boundary.
  thickness | The thickness of the polygon boundary (going inside the polygon).
  color | The 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_point | callback functor that provides the list of points delimiting the outer boundary of the polygon.
  thickness | The thickness of the polygon boundary (going inside the polygon).
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points of the polygon.
  color | The 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_point | callback functor that provides the list of points delimiting the polygon.
  color | The 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

  nbpoints | number of points in tabPoints.
  tabPoints | array of points of the polygon
  thickness | The thickness of the polygon boundary (going 'inside' the polygon).
  interior_color | color for the interior
  border_color | color 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_point | callback functor that provides the list of points delimiting the polygon outer boundary.
  thickness | The thickness of the polygon boundary (going 'inside' the polygon)
  interior_color | color for the interior
  border_color | color 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

  center | Circle center.
  r | radius.
  color | color.
  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

  center | Circle center.
  r | radius.
  interior_color | color for the interior.
  outline_color | color 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

  center | Circle center.
  r | radius.
  color | color
  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

  center | Circle center.
  r | external radius (the internal radius is r - thickness).
  thickness | thickness (going inside the circle).
  color | color.
  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

  center | Circle center.
  r | radius.
  color | color.
  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

  center | Circle center.
  r | external radius (the internal radius is r - thickness).
  thickness | thickness 'going inside the circle'
  color_interior | color of the interior
  color_border | color 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

  center | circle center position.
  r | circle radius.
  angle_start | angle in degrees of the begigining of the arc.
  angle_end | angle in degrees of the end of the arc.
  color | color 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

  center | circle center position.
  r | circle radius.
  angle_start | angle in degrees of the begigining of the arc.
  angle_end | angle in degrees of the end of the arc.
  thickness | The thickness of the arc, going 'inside' the circle.
  color | color 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

  center | circle center position.
  r | circle radius.
  angle_start | angle in degrees of the begigining of the arc.
  angle_end | angle in degrees of the end of the arc.
  color | color 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

  center | circle center position.
  r | circle radius.
  angle_start | angle in degrees of the begigining of the arc.
  angle_end | angle in degrees of the end of the arc.
  thickness | border thickness going 'inside' the circle.
  color_interior | color for the interior.
  color_border | color 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

  center | Circle center.
  radiuses | radiuses along the x and y axis.
  color | color.
  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

  center | Circle center.
  radiuses | radiuses along the x and y axis.
  interior_color | color for the interior.
  outline_color | color 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

  center | Ellipse center.
  radiuses | radiuses along the x and y axis.
  color | color.
  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

  center | Ellipse center.
  radiuses | external radiuses along the x and y axis.
  thickness | thickness going 'inside' the ellipse
  color | color.
  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

  center | Ellipse center.
  radiuses | radiuses along the x and y axis.
  color | color.
  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

  center | ellipse center.
  radiuses | radiuses along the x and y axis.
  thickness | border thickness going 'inside' the ellipse
  color_interior | color of the interior.
  color_border | color 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

  P1 | Start point.
  P2 | End point.
  PC | Control point.
  wc | Control point weight (must be > 0). Fastest for wc=1.
  drawP2 | true to draw the endpoint P2.
  color | The color to use.
  opacity | Opacity 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

  P1 | Start point.
  P2 | End point.
  PA | first control point.
  PB | second control point.
  drawP2 | true to draw the endpoint P2.
  color | The color to use.
  opacity | Opacity 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  draw_last_point | true to draw the last point.
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  draw_last_point | true to draw the last point.
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  color | The 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

  P1 | Start point.
  P2 | End point.
  PC | Control point.
  wc | Control point weight (must be >0).
  thickness | thickness of the curve.
  end_P1 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_P2 | specify how the extremity P2 should be drawn (c.f. tgx::EndPath enum)
  color | The 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

  P1 | Start point.
  P2 | End point.
  PA | first control point.
  PB | second control point.
  thickness | thickness of the curve.
  end_P1 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_P2 | specify how the extremity P2 should be drawn (c.f. tgx::EndPath enum)
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  thickness | thickness of the curve.
  end_P0 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_Pn | specify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  thickness | thickness of the curve.
  end_P0 | specify how the extremity P0 should be drawn (c.f. tgx::EndPath enum)
  end_Pn | specify how the extremity Pn should be drawn (c.f. tgx::EndPath enum)
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  thickness | thickness of the curve.
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  color | The 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_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack)

Parameters

  nbpoints | number of points in the spline Must be smaller or equal to SPLINE_MAX_POINTS.
  tabPoints | the array of points to interpolate.
  thickness | thickness of the curve.
  color_interior | The color to use.
  color_border | The 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

  font | The 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

  font | The 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

  | c | The character.
  | pos | position of the anchor point in this image.
  | font | The 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] | xadvance | If 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 `font`when 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

  | c | The character.
  | pos | position of the anchor point in this image.
  | font | The 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] | xadvance | If 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 `font`when 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

  text | The text.
  pos | position of the anchor point in the image.
  font | The 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

  text | The text.
  pos | position of the anchor point in the image.
  font | The 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

  c | The character to draw.
  pos | Location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
  font | The font to use.
  color | The 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

  c | The character to draw.
  pos | Location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
  font | The font to use.
  color | The 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

  text | The text to draw.
  pos | Location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
  font | The font to use.
  color | The 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

  text | The text to draw.
  pos | Location of the anchor with respect to the char bounding box. (by default, this is the BASELINE|LEFT).
  font | The font to use.
  color | The 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,
|  | const GFXfont & | font,
|  | Anchor | anchor,
|  | 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

  text | The text to draw.
  pos | position to draw the text. This is the position to which will be mapped the selected anchor point of the text.
  font | The font to use.
  anchor | Select the anchor point of the text c.f. enum tgx::Anchor (the `drawText()` methods uses `BASELINE|LEFT`).
  wrap_text | True to wrap wrap text at the end of image. Wrapping occur per character (not per word).
  start_newline_at_0 | True to start a new line of text at position x=0 and false to start at x=pos.x.
  color | The 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,
|  | const ILI9341_t3_font_t & | font,
|  | Anchor | anchor,
|  | 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

  text | The text to draw.
  pos | position to draw the text. This is the position to which will be mapped the selected anchor point of the text.
  font | The font to use.
  anchor | Select the anchor point of the text c.f. enum tgx::Anchor (the `drawText()` methods uses `BASELINE|LEFT`).
  wrap_text | True to wrap wrap text at the end of image. Wrapping occur per character (not per word).
  start_newline_at_0 | True to start a new line of text at position x=0 and false to start at x=pos.x.
  color | The 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).

## ◆ setOpenFontRender()

template<typename color_t >
template<typename T >

void tgx::Image< color_t >::setOpenFontRender | ( | T & | ofr,
|  | float | opacity = `TGX_DEFAULT_NO_BLENDING`
| ) |  |
| inline

Link the image with Takkoa's OpenFontRender library : https://github.com/takkaO/OpenFontRender.

Template Parameters

  T | type of the font renderer i.e. here it is `OpenFontRender` for Takkao's library.

Parameters

  [in,out] | ofr | The font renderer object to link with.
  | opacity | (Optional) Opacity multiplier (in [0.0f, 1.0f]) used when drawing the font.

## ◆ PNGDecode()

template<typename color_t >
template<typename PNG_T >

int tgx::Image< color_t >::PNGDecode | ( | PNG_T & | png,
|  | iVec2 | topleft = `iVec2(0, 0)`,
|  | float | opacity = `1.0f`
| ) |  |

Decode a PNG image into this image using the PNGDec library: https://github.com/bitbank2/PNGdec/.

This method is a wrapper around the `PNG.decode()` method from the PNGDec library and takes the same arguments and return values.

The image is cropped if it does not fit completely into this image.

Template Parameters

  PNG_T | Type of the PNG decoder i.e. here it is `PNG` from BitBank2's PNGDec library.

Parameters

  [in,out] | png | The PNG decoder object. TGX must have been linked previously with this object when calling one of the `open` methods by passing `TGX_PNGDraw` as argument for the PNGDraw callback.
  | topleft | (Optional) Position of the top-left corner of the PNG inside this image. May be outside the image boundary and the PNG will be cropped accordingly.
  | opacity | (Optional) Opacity multiplier when blending in [0.0f, 1.0f].

Returns
  The error code associated with the PNG.decode() method. (0 in case of success, 1000 if this image is invalid).

## ◆ JPEGDecode()

template<typename color_t >
template<typename JPEG_T >

int tgx::Image< color_t >::JPEGDecode | ( | JPEG_T & | jpeg,
|  | iVec2 | topleft = `iVec2(0, 0)`,
|  | int | options = `0`,
|  | float | opacity = `1.0f`
| ) |  |

Decode a JPEG image into this image using the JPEGDEC library: https://github.com/bitbank2/JPEGDEC/.

This method is a wrapper around the `JPEGDEC.decode()` method from the JPEGDEC library and takes the same arguments and return values.

The image is cropped if it does not fit completely into this image.

Template Parameters

  JPEG_T | Type of the JPEG decoder i.e. here it is `JPEGDEC` from BitBank2's JPEGDEC library.

Parameters

  [in,out] | jpeg | The JPEG decoder object. TGX must have been linked previously with this object when calling one of the `open` methods by passing `TGX_JPEGDraw` as argument for the JPEGDraw callback.
  | topleft | (Optional) Position of the top-left corner of the JPEG inside this image. May be outside the image boundary and the JPEG will be cropped accordingly.
  | options | (Optional) Options to pass to the decoder. See the JPEGDEC library for the list of options available (currently: JPEG_AUTO_ROTATE, JPEG_SCALE_HALF, JPEG_SCALE_QUARTER, JPEG_SCALE_EIGHTH, JPEG_LE_PIXELS, JPEG_EXIF_THUMBNAIL, JPEG_LUMA_ONLY). Set this to 0 for default option.
  | opacity | (Optional) Opacity multiplier when blending in [0.0f, 1.0f].

Returns
  The error code associated with the jpeg.decode() method. (0 in case of success, 1000 if this image is invalid).

## ◆ GIFplayFrame()

template<typename color_t >
template<typename GIF_T >

int tgx::Image< color_t >::GIFplayFrame | ( | GIF_T & | gif,
|  | iVec2 | topleft = `iVec2(0, 0)`,
|  | float | opacity = `1.0f`
| ) |  |

Decode a (possibly animated) GIF image into this image using the AnimatedGIF library: https://github.com/bitbank2/AnimatedGIF/.

This method is a wrapper around the `JPEGDEC.playFrame()` method from the AnimatedGIF library and takes the same arguments and return values.

- In the case of animated GIF. Each call to the method draws the nexct frame. The method returns 1 when there is still another frame to draw, 0 when finished. See the `gif.playFrame()` method from the AnimatedGIF library for additional details.
- The image is cropped if it does not fit completely into this image.

Template Parameters

  GIF_T | Type of the GIF decoder i.e. here it is `AnimatedGIF` from BitBank2's AnimatedGIF library.

Parameters

  [in,out] | gif | The GIF decoder object. TGX must have been linked previously with this object when calling one of the `open` methods by passing `TGX_GIFDraw` as argument for the GIFDraw callback.
  | topleft | (Optional) Position of the top-left corner of the GIF inside this image. May be outside the image boundary and the GIF will be cropped accordingly.
  | opacity | (Optional) Opacity multiplier when blending in [0.0f, 1.0f]. NOTE: only opaque mode (opacity=1.0f) is supported for GIF animation.

Returns
  The error code associated with the gif.playFrame() method. (0 in case of success, 1000 if this image is invalid).

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

- src/Image.h