GpiTranslate, GpiRotate, and GpiScale provide a convenient method for transforming objects in a picture. The following figure shows how to use these functions to translate, rotate, and scale a triangle.
MATRIXLF matlfTransform;
POINTL ptlStart, ptlTrans, ptlRotate, ptlScale;
FIXED fxAngle, afxScale[2];
POINTL aptlTriangle[] = { 575, 300, 575, 500, 500, 300 };
ptlStart.x = 500; /* Starting point x direction */
ptlStart.y = 300; /* Starting point y direction */
GpiMove(hps, &ptlStart);
GpiPolyLine(hps, sizeof(aptlTriangle) / sizeof(POINTL), aptlTriangle);
ptlTrans.x = 75; /* x coordinate for translation */
ptlTrans.y = 75; /* y coordinate for translation */
GpiTranslate(hps, /* Presentation-space handle */
&matlfTransform, /* Address of matrix */
TRANSFORM_REPLACE, /* Replace old matrix with new */
&ptlTrans); /* Coordinates for translation */
GpiSetModelTransformMatrix(hps, /* Presentation-space handle */
9, /* Number of points in matrix */
&matlfTransform, /* Address of matrix */
TRANSFORM_REPLACE); /* Replace old matrix with new */
GpiMove(hps, &ptlStart); /* Move to starting point */
GpiPolyLine(hps, sizeof(aptlTriangle) / sizeof(POINTL), aptlTriangle);
fxAngle = MAKEFIXED(-45, 0); /* Rotate 45 degrees clockwise */
ptlRotate.x = 550; /* x coordinate rotation origin */
ptlRotate.y = 350; /* y coordinate rotation origin */
GpiRotate(hps, /* Presentation-space handle */
&matlfTransform, /* Address of matrix */
TRANSFORM_REPLACE, /* Replace old matrix with new */
fxAngle, /* Rotation angle */
&ptlRotate); /* Origin of rotation */
GpiSetModelTransformMatrix(hps, 9, &matlfTransform, TRANSFORM_REPLACE);
GpiMove(hps, &ptlStart); /* Move to starting point */
GpiPolyLine(hps, sizeof(aptlTriangle) / sizeof(POINTL), aptlTriangle);
ptlScale.x = 550; /* x coordinate scale origin */
ptlScale.y = 350; /* y coordinate scale origin */
afxScale[0] = MAKEFIXED(2, 0); /* Scaling factor on x axis */
afxScale[1] = MAKEFIXED(2, 0); /* Scaling factor on y axis */
GpiScale(hps, /* Presentation-space handle */
&matlfTransform, /* Address of matrix */
TRANSFORM_REPLACE, /* Replace old matrix with new */
&afxScale[0], /* Scaling factor */
&ptlScale); /* Origin of scaling operation */
GpiSetModelTransformMatrix(hps, 9, &matlfTransform, TRANSFORM_REPLACE);
GpiMove(hps, &ptlStart); /* Move to starting point */
GpiPolyLine(hps, sizeof(aptlTriangle) / sizeof(POINTL), aptlTriangle);