uLib  User mode C/C++ extended API library for Win32 programmers.

Module Description

XFORM transformation support

Two dimensional transformations, used for e.g SetWorldTransform(),
are matrix operations with this general definition.

[x'y'1] = [x y 1] | eM11 eM12 0 |
| eM21 eM22 0 |
| eDx eDy 1 |
x' = x * eM11 + y * eM21 + eDx;
y' = y * eM12 + y * eM22 + eDy;

The individual transforms defined by these functions can be combined
into composite transformations using the GDI CombineTransform() function.
Note: To use HDC world transforms you must set the HDC mode to 'advanced'
by calling SetGraphicsMode( hdc, GM_ADVANCED ).
XFORM transformations are also used for ExtCreateRegion().

Macros

#define ClearXform(pxfm)   SetXformScale( pxfm, 1.0f, 1.0f )
 
#define AppendXform(Dst, append)   CombineTransform( (XFORM*)(Dst), (XFORM*)(Dst), (XFORM*)(append) )
 
#define PrependXform(Dst, prepend)   CombineTransform( (XFORM*)(Dst), (XFORM*)(prepend), (XFORM*)(Dst) )
 

Functions

XFORM * SetXformTranslate (XFORM *pxfm, float dx, float dy)
 
XFORM * SetXformScale (XFORM *pxfm, float dx, float dy)
 
XFORM * SetXformRotate (XFORM *pxfm, double angle)
 
XFORM * SetXformShear (XFORM *pxfm, float sx, float sy)
 
XFORM * SetXformReflect (XFORM *pxfm, bool rx, bool ry)
 

Macro Definition Documentation

◆ ClearXform

#define ClearXform (   pxfm)    SetXformScale( pxfm, 1.0f, 1.0f )

ClearXform() sets the XFORM to the identity matrix (no transform).

Definition at line 2273 of file UtilFunc.h.

◆ AppendXform

#define AppendXform (   Dst,
  append 
)    CombineTransform( (XFORM*)(Dst), (XFORM*)(Dst), (XFORM*)(append) )

AppendXform() combines two transforms, with 'Dst' as the primary.

Definition at line 2277 of file UtilFunc.h.

◆ PrependXform

#define PrependXform (   Dst,
  prepend 
)    CombineTransform( (XFORM*)(Dst), (XFORM*)(prepend), (XFORM*)(Dst) )

PrependXform() combines two transforms, with 'prepend' as the primary.

Definition at line 2282 of file UtilFunc.h.

Function Documentation

◆ SetXformTranslate()

XFORM* SetXformTranslate ( XFORM *  pxfm,
float  dx,
float  dy 
)

SetXformTranslate() sets a translation (move) matrix.
Translate: x' = x + dx ; y' = y + dy
The function returns the XFORM* passed in (for chaining).

Definition at line 21 of file Xform.cpp.

◆ SetXformScale()

XFORM* SetXformScale ( XFORM *  pxfm,
float  dx,
float  dy 
)

SetXformScale() sets a scaling transform.
Scale: x' = x * dx ; y' = y * dy
The function returns the XFORM* passed in (for chaining).

Definition at line 34 of file Xform.cpp.

◆ SetXformRotate()

XFORM* SetXformRotate ( XFORM *  pxfm,
double  angle 
)

SetXformRotate() sets a rotation transform.
Note: Rotation is around the origin {0,0}, so to rotate around
another point, first translate (move) to the desired distance from
the origin, then rotate, and finally translate back to the destination.

x' = (x * cos A) - (y * sin A);
y' = (x * sin A) + (y * cos A)

The function returns the XFORM* passed in (for chaining).

Definition at line 47 of file Xform.cpp.

◆ SetXformShear()

XFORM* SetXformShear ( XFORM *  pxfm,
float  sx,
float  sy 
)

SetXformShear() sets a shearing transform.
Shear: x' = x + (Sx * y) ; y' = y + (Sy * x)
The function returns the XFORM* passed in (for chaining).

Definition at line 62 of file Xform.cpp.

◆ SetXformReflect()

XFORM* SetXformReflect ( XFORM *  pxfm,
bool  rx,
bool  ry 
)

SetXformReflect() sets a reflection (mirror) transform.
Reflect: x' = -x ; y' = -y
The function returns the XFORM* passed in (for chaining).

Definition at line 75 of file Xform.cpp.