Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

DynaPDF Manual - Page 545

Previous Page 544   Index   Next Page 546

Function Reference
Page 545 of 766
Transform(M, x1, y1);
Transform(M, x2, y2);
if (x1 > x2)
return -CalcDistance(x1, y1, x2, y2);
else
return CalcDistance(x1, y1, x2, y2);
}
// Scaling factor of the y-axis
double GetScaleY(TCTM &M)
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 0.0;
double y2 = 1.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
if (y1 > y2)
return -CalcDistance(x1, y1, x2, y2);
else
return CalcDistance(x1, y1, x2, y2);
}
// Multiply two matrices. Note that matrix multiplications are not
// commutative. It is a difference whether the matrix M1 is multiplied
// with M2 or vice versa!
TCTM MulMatrix(TCTM &M1, TCTM &M2)
{
TCTM retval;
retval.a = M2.a * M1.a + M2.b * M1.c;
retval.b = M2.a * M1.b + M2.b * M1.d;
retval.c = M2.c * M1.a + M2.d * M1.c;
retval.d = M2.c * M1.b + M2.d * M1.d;
retval.x = M2.x * M1.a + M2.y * M1.c + M1.x;
retval.y = M2.x * M1.b + M2.y * M1.d + M1.y;
return retval;
}
// Transform a point with a matrix
void Transform(TCTM &M, double &x, double &y)
{
double tx = x;
x = tx * M.a + y * M.c + M.x;
y = tx * M.b + y * M.d + M.y;
}
Text Coordinates and Metrics
As mentioned earlier text coordinates are defined in text space. The transformation from text space
to user space is achieved by multiplying the text matrix with the one of the current graphics state.
However, the graphics state contains several text related parameters which require some further
explanation. The following sub-clauses describe in detail in which coordinate space these parameters
 

Previous topic: Helper Functions

Next topic: Text Width