GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Macros
gp_transform.h File Reference

Coordinate transformations for gp_pixmap swap flags. More...

#include <core/gp_common.h>

Go to the source code of this file.

Macros

#define GP_TRANSFORM_X(pixmap, x)
 Flips x coordinate within pixmap according to the x_swap flag.
 
#define GP_TRANSFORM_Y(pixmap, y)
 Flips y coordinate within pixmap according to the y_swap flag.
 
#define GP_TRANSFORM_SWAP(pixmap, x, y)
 Swaps coordinates within pixmap according to the axes_swap flag.
 
#define GP_TRANSFORM_POINT(pixmap, x, y)
 Does the complete coordinate transformation accordingly to transformation flags.
 
#define GP_TRANSFORM_RECT(pixmap, x, y, w, h)
 Transforms a rectangle accordingly to the transformation flags.
 
#define GP_RETRANSFORM_POINT(pixmap, x, y)
 An inverse transformation to GP_TRANSFORM_POINT().
 

Detailed Description

Coordinate transformations for gp_pixmap swap flags.

These transformations are applied before a complex shapes are rendered into a gp_pixmap, e.g. each polygon coordinate is transformed before the polygon rendering algorithm starts.

Definition in file gp_transform.h.

Macro Definition Documentation

◆ GP_RETRANSFORM_POINT

#define GP_RETRANSFORM_POINT (   pixmap,
  x,
 
)
Value:
do { \
GP_TRANSFORM_X(pixmap, x); \
GP_TRANSFORM_Y(pixmap, y); \
GP_TRANSFORM_SWAP(pixmap, x, y); \
} while (0)

An inverse transformation to GP_TRANSFORM_POINT().

Used to translate mouse pointer coordinates to coordinates on pixmap.

Attention
Modifies the x and y variables passed as argument.
Parameters
pixmapA pixmap.
xAn x coordinate that may be transformed.
yAn y coordinate that may be transformed.

Definition at line 129 of file gp_transform.h.

◆ GP_TRANSFORM_POINT

#define GP_TRANSFORM_POINT (   pixmap,
  x,
 
)
Value:
do { \
GP_TRANSFORM_SWAP(pixmap, x, y); \
GP_TRANSFORM_X(pixmap, x); \
GP_TRANSFORM_Y(pixmap, y); \
} while (0)

Does the complete coordinate transformation accordingly to transformation flags.

Uses the gp_pixmap::axes_swap, gp_pixmap::x_swap and gp_pixmap::y_swap flags to transform the coordinates.

Attention
Modifies the x and y variables passed as argument.
Parameters
pixmapA pixmap.
xAn x coordinate that may be transformed.
yAn y coordinate that may be transformed.

Definition at line 78 of file gp_transform.h.

◆ GP_TRANSFORM_RECT

#define GP_TRANSFORM_RECT (   pixmap,
  x,
  y,
  w,
 
)
Value:
do { \
GP_TRANSFORM_SWAP(pixmap, x, y); \
GP_TRANSFORM_SWAP(pixmap, w, h); \
\
if ((pixmap)->x_swap) \
x = (pixmap)->w - x - w; \
\
if ((pixmap)->y_swap) \
y = (pixmap)->h - y - h; \
} while (0)

Transforms a rectangle accordingly to the transformation flags.

Attention
Modifies the x, y, w, and h variables passed as argument.
Parameters
pixmapA pixmap.
xA left x coordinate of a rectangle.
yA top y coordinate of a rectangle.
wA rectangle width.
hA rectangle height.

Definition at line 95 of file gp_transform.h.

◆ GP_TRANSFORM_SWAP

#define GP_TRANSFORM_SWAP (   pixmap,
  x,
 
)
Value:
do { \
if ((pixmap)->axes_swap) \
GP_SWAP(x, y); \
} while (0)

Swaps coordinates within pixmap according to the axes_swap flag.

Attention
Modifies the x and y variables passed as argument.
Parameters
pixmapA pixmap.
xAn x coordinate that may be swapped with y coordinate.
yAn y coordinate that may be swapped with x coordinate.

Definition at line 60 of file gp_transform.h.

◆ GP_TRANSFORM_X

#define GP_TRANSFORM_X (   pixmap,
 
)
Value:
do { \
if ((pixmap)->x_swap) \
x = (pixmap)->w - x - 1; \
} while (0)

Flips x coordinate within pixmap according to the x_swap flag.

Attention
Modifies the y variable passed as argument.
Parameters
pixmapA pixmap.
xAn x coordinate that may be flipped.

Definition at line 33 of file gp_transform.h.

◆ GP_TRANSFORM_Y

#define GP_TRANSFORM_Y (   pixmap,
 
)
Value:
do { \
if ((pixmap)->y_swap) \
y = (pixmap)->h - y - 1; \
} while (0)

Flips y coordinate within pixmap according to the y_swap flag.

Attention
Modifies the y variable passed as argument.
Parameters
pixmapA pixmap.
yAn y coordinate that may be flipped.

Definition at line 46 of file gp_transform.h.