DynaPDF Manual - Page 615

Previous Page 614 Index Next Page 616

Function Reference

Page 615 of 777

RotateCoords

Syntax:

LBOOL pdfRotateCoords(

const PPDF* IPDF, // Instance pointer

double alpha,

// Angle alpha in degrees

double OriginX,

// Origin of the x-axis

double OriginY)

// Origin of the y-axis

The function rotates the coordinate system at the point OriginX, OriginY by applying a

transformation matrix. It is highly recommended to save the graphics state beforehand, otherwise it

is very difficult or impossible to restore the coordinate system later.

After the coordinate system was changed by the function, bottom-up coordinates are active. It is not

possible to use top-down coordinates with a rotated coordinate system.

A rotation is internally calculated as follows:

TCTM M; // Transformation matrix, the data type is declared in dynapdf.h

double si, co;

si

= sin(alpha * PI / 180.0);

co

= cos(alpha * PI / 180.0);

M.a = co;

M.b = si;

M.c = -si;

M.d = co;

M.x = OriginX;

m.y = OriginY;

Note that the origin of the rotation must be set to that position where the coordinates should be

rotated. Consider also the new coordinate origin when printing objects into the rotated coordinate

system.

Example:

pdfSaveGraphicState(pdf);

pdfRotateCoords(pdf, 30.0, 150.0, 450.0); // Set the correct origin

// We don't want to move the rectangle inside the rotated coordinate

// system; the rectangle must be printed at 0, 0 because the origin was

// already set

pdfRectangle(pdf, 0.0, 0.0, 200.0, 100.0, fmStroke);

pdfRestoreGraphicState(pdf);

Remarks:

If the graphics state was not saved beforehand the function sets a warning but the transformation is

applied.

Return values:

If the function succeeds the return value is 1. If the function fails the return value is 0.

Previous topic: ResizeBitmap (Rendering Engine), RestoreGraphicState

Next topic: RoundRect