![]() |
TGX 1.0.3
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
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.
| |
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
| |
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.
| |
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.
| |
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:
| |
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. | |
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.
color_t | Color type of the image. Must be one of the color type defined in Color.h. Typical choice: |
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:
_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).HSV
as color type for an image: it has not been tested to work and will be very slow.The library defines many drawing primitives with naming convention:
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).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: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.0.0f < opacity <= 1.0f
will enable blending and the alpha channel of the colors will be used if present.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)
.
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.tgx::Image< color_t >::Image | ( | ) |
Default constructor.
Create a empty (invalid) image.
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.
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). |
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.
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). |
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.
im | The source image. |
subbox | The region of the source image to use for this image. |
|
default |
Default copy constructor.
Copy is shallow: both images share the same memory buffer.
im | The source image. |
|
default |
Default assignement operator.
Copy is shallow: both images share the same memory buffer.
im | The source image. |
void tgx::Image< color_t >::set | ( | T * | buffer, |
int | lx, | ||
int | ly, | ||
int | stride = DEFAULT_STRIDE |
||
) |
Set/update the image 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. |
void tgx::Image< color_t >::set | ( | T * | buffer, |
iVec2 | dim, | ||
int | stride = DEFAULT_STRIDE |
||
) |
Set/update the image 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. |
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).
subbox | The region to to keep. |
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.
subbox | The region to to keep. |
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)
B | box that delimit the sub-image inside this image. |
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))
min_x | left boundary (inclusive) |
max_x | right boundary (inclusive) |
min_y | top boundary (inclusive) |
max_y | bottom boundary (inclusive) |
|
inline |
Query if the image is valid.
void tgx::Image< color_t >::setInvalid | ( | ) |
Set the image as invalid.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the image stride.
|
inline |
Return the image dimensions as an iVec2.
|
inline |
Return the image dimension as a box.
|
inline |
Return a pointer to the pixel buffer.
const overload.
|
inline |
Return a pointer to the pixel buffer.
non-const overload.
|
inline |
Set a pixel at a given position.
CHECKRANGE | set to false to disable range checking (danger!) |
pos | position. |
color | color to set. |
|
inline |
Set a pixel at a given position (floating point coord).
[-0.5f, lx-0.5f]x[-0.5f,lx-0.5f]
and center of pixels are on the interger lattice.CHECKRANGE | set to false to disable range checking (danger!) |
pos | position given as a floating point value vector. |
color | color to set. |
|
inline |
Blend a pixel with the current pixel color.
CHECKRANGE | set to false to disable range checking (danger!) |
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. |
|
inline |
Blend a pixel with the current pixel color (floating point coord).
[-0.5f, lx-0.5f]x[-0.5f,lx-0.5f]
and center of pixels are on the interger lattice.CHECKRANGE | set to false to disable range checking (danger!) |
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. |
|
inline |
Return the color of a pixel at a given position.
CHECKRANGE | If set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!) |
pos | The position to read. |
outside_color | (Optional) color to return when querying outside the range. |
|
inline |
Return the color of a pixel at a given position (floating point coord).
[-0.5f, lx-0.5f]x[-0.5f,lx-0.5f]
and center of pixels are on the interger lattice.CHECKRANGE | If set to true, outside_color is returned when querying outside of the image range. Otherwise nor range checking is performed (danger!) |
pos | The position to read given as a floating point value vector. |
outside_color | (Optional) color to return when querying outside the range. |
|
inline |
Get a reference to a pixel (no range check!)
const overload.
pos | The position. |
|
inline |
Get a reference to a pixel (no range check!)
non-const overload.
pos | The position. |
|
inline |
Get a reference to a pixel (no range check!)
const overload.
x | x-coordinate. |
y | y-coordinate. |
|
inline |
Get a reference to a pixel (no range check!)
non-const overload.
x | x-coordinate. |
y | y-coordinate. |
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 imagecolor
is a reference to the current pixel color.im
: cb_fun | The callback function. |
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.
cb_fun | The callback function. |
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.
cb_fun | The callback function. |
B | The sub-box to iterate inside. |
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.
cb_fun | The callback function. |
B | The sub-box to iterate inside. |
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.
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. |
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).
sprite | The sprite image to blend. |
upperleftpos | Position of the upper left corner of the sprite in the image. |
blend_op | The blending operator. |
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.
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. |
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).
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. |
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).
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. |
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.
[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. |
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.
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... |
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. |
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.
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... |
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. |
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.
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... |
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. |
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 !
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. |
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).
src_im | Source image to copy onto this image. |
blend_op | The blending operator. |
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.
src_image | the source image. |
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.
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.
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()
.color_dst | Color type to convert the image into. |
color_dest
. void tgx::Image< color_t >::fillScreen | ( | color_t | color | ) |
Fill the whole image with a single color.
same as clear(color)
color | The color to use. |
void tgx::Image< color_t >::clear | ( | color_t | color | ) |
Fill the whole image with a single color.
Same as fillScreen(color)
.
color | The color to use. |
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).
top_color | color at the top of the image. |
bottom_color | color at the bottom of the image. |
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).
left_color | color on the left side of the image. |
right_color | color on the right side of the image. |
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.
STACK_SIZE | size allocated on the stack (in bytes). |
start_pos | Start position. The color to replace is the color at that position. |
new_color | New color to use. |
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.
new_color
is treated the same as border_color
and will also block the filling procedure when encountered.STACK_SIZE | size allocated on the stack (in bytes). |
start_pos | Start position. |
border_color | border color that delimits the connected component to fill. |
new_color | New color to use. |
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
.
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. |
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.
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. |
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).
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. |
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.
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. |
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].
P1 | The first point. |
P2 | The second point. |
color | color to use. |
opacity | opacity multiplier between 0.0f and 1.0f (default). |
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].
drawWideLine()
method.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). |
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].
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). |
void tgx::Image< color_t >::drawRect | ( | const iBox2 & | B, |
color_t | color, | ||
float | opacity = TGX_DEFAULT_NO_BLENDING |
||
) |
Draw a rectangle.
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. |
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.
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. |
void tgx::Image< color_t >::fillRect | ( | const iBox2 & | B, |
color_t | color, | ||
float | opacity = TGX_DEFAULT_NO_BLENDING |
||
) |
Draw a filled rectangle.
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. |
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.
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. |
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.
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. |
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.
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. |
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].
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]. |
void tgx::Image< color_t >::fillRectAA | ( | const fBox2 & | B, |
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a filled rectangle [High quality].
B | Box representing the rectngle to daw. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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
.
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. |
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
.
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. |
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].
B | box that delimits the rectangle to draw. |
corner_radius | corner radius. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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].
B | box that delimits the rectangle to draw. |
corner_radius | corner radius. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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.
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. |
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.
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. |
void tgx::Image< color_t >::drawTriangleAA | ( | fVec2 | P1, |
fVec2 | P2, | ||
fVec2 | P3, | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a triangle [High quality].
P1 | first vertex. |
P2 | second vertex. |
P3 | third vertex. |
color | The color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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].
P1 | first vertex. |
P2 | second vertex. |
P3 | third vertex. |
color | The color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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.
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. |
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.
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. |
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).
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 |
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.
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. |
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)
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). |
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
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). |
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.
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. |
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.
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. |
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].
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]. |
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].
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]. |
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].
P1 | first vertex. |
P2 | second vertex. |
P3 | third vertex. |
P4 | fourth vertex. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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].
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]. |
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.
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.
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.
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.
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.
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.
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].
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. |
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:
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.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. |
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).
nbpoints | number of points in tabPoints. |
tabPoints | array of points. |
color | The color to use. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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.next_point | callback functior that privdes the list of points. |
color | The color to use. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
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]. |
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).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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.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]. |
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].
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. |
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:
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.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. |
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].
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. |
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:
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 !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. |
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).
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. |
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).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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.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. |
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).
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]. |
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).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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 !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]. |
void tgx::Image< color_t >::fillPolygonAA | ( | int | nbpoints, |
const fVec2 | tabPoints[], | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a filled polygon (High quality).
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]. |
void tgx::Image< color_t >::fillPolygonAA | ( | FUNCTOR_NEXT | next_point, |
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a filled polygon (High quality).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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 !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]. |
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).
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]. |
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).
Points are queried in order P0, P1,... using a functor callback which must have a signature compatible with:
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 !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]. |
void tgx::Image< color_t >::drawCircle | ( | iVec2 | center, |
int | r, | ||
color_t | color, | ||
float | opacity = TGX_DEFAULT_NO_BLENDING |
||
) |
Draw a circle.
center | Circle center. |
r | radius. |
color | color. |
opacity | (Optional) Opacity multiplier when blending (in [0.0f, 1.0f]) or negative to disable blending. |
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.
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. |
void tgx::Image< color_t >::drawCircleAA | ( | fVec2 | center, |
float | r, | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a circle (high quality).
center | Circle center. |
r | radius. |
color | color |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
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]. |
void tgx::Image< color_t >::fillCircleAA | ( | fVec2 | center, |
float | r, | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a filled circle (high quality).
center | Circle center. |
r | radius. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
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]. |
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).
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 |
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]. |
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).
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 |
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]. |
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).
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 |
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]. |
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).
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 |
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]. |
void tgx::Image< color_t >::drawEllipse | ( | iVec2 | center, |
iVec2 | radiuses, | ||
color_t | color, | ||
float | opacity = TGX_DEFAULT_NO_BLENDING |
||
) |
Draw an ellipse.
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. |
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.
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. |
void tgx::Image< color_t >::drawEllipseAA | ( | fVec2 | center, |
fVec2 | radiuses, | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw an ellipse (high quality).
center | Ellipse center. |
radiuses | radiuses along the x and y axis. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
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]. |
void tgx::Image< color_t >::fillEllipseAA | ( | fVec2 | center, |
fVec2 | radiuses, | ||
color_t | color, | ||
float | opacity = 1.0f |
||
) |
Draw a filled ellipse (high quality).
center | Ellipse center. |
radiuses | radiuses along the x and y axis. |
color | color. |
opacity | (Optional) Opacity multiplier in [0.0f, 1.0f]. |
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).
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]. |
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.
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. |
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.
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. |
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
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. |
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).
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. |
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).
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
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).
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).
SPLINE_MAX_POINTS | Max number of point interpolation point in the sline. Adjust if needed (but uses more memory on stack) |
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. |
int tgx::Image< color_t >::fontHeight | ( | const GFXfont & | font | ) | const |
Query the height of a font.
overload for GFXfont
.
tgx::fontHeight(const GFXfont & font)
.font | The font. |
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
.
tgx::fontHeight(const ILI9341_t3_font_t& font)
.font | The font. |
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
.
tgx::measureChar(char c, iVec2 pos, const GFXfont& font, Anchor anchor, int* xadvance)
.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. |
font
when its chosen anchor is at pos
. 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
.
tgx::measureChar(char c, iVec2 pos, const ILI9341_t3_font_t& font, Anchor anchor, int* xadvance)
.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. |
font
when its chosen anchor is at pos
. 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
.
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. |
text
draw with font
when its chosen anchor is at pos
. 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
.
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. |
text
draw with font
when its chosen anchor is at pos
. 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
.
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. |
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
.
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. |
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
.
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. |
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
.
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. |
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
.
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. |
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
.
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. |
|
inline |
Link the image with Takkoa's OpenFontRender library : https://github.com/takkaO/OpenFontRender.
T | type of the font renderer i.e. here it is OpenFontRender for Takkao's library. |
[in,out] | ofr | The font renderer object to link with. |
opacity | (Optional) Opacity multiplier (in [0.0f, 1.0f]) used when drawing the font. |
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.
PNG_T | Type of the PNG decoder i.e. here it is PNG from BitBank2's PNGDec library. |
[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]. |
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.
JPEG_T | Type of the JPEG decoder i.e. here it is JPEGDEC from BitBank2's JPEGDEC library. |
[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]. |
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.
gif.playFrame()
method from the AnimatedGIF library for additional details.GIF_T | Type of the GIF decoder i.e. here it is AnimatedGIF from BitBank2's AnimatedGIF library. |
[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. |