Shearing a Picture

The following figure is an example of shearing a picture by modifying the transformation matrix directly.

   MATRIXLF matlfTransform;
   POINTL ptlStart, ptlEnd;

   ptlStart.x = 500;          /* x coordinate, lower-left corner of box   */
   ptlStart.y = 300;          /* y coordinate, lower-left corner of box   */
   GpiMove(hps, &ptlStart);
   ptlEnd.x = 700;      ;     /* x coordinate, upper-right corner of box  */
   ptlEnd.y = 500;      ;     /* y coordinate, upper-right corner of box  */
   GpiBox(hps, DRO_OUTLINE, &ptlEnd, 0, 0);  /* Draw first box            */

    matlfTransform.fxM11 = MAKEFIXED(1, 0);
    matlfTransform.fxM12 = MAKEFIXED(0, 0);
    matlfTransform.lM13 = 0;
    matlfTransform.fxM21 = MAKEFIXED(0, 65536 / 2);  /* Shear factor .5   */
    matlfTransform.fxM22 = MAKEFIXED(1, 0);
    matlfTransform.lM23 = 0;
    matlfTransform.lM31 = 200;               /* Translate 200 units right */
    matlfTransform.lM32 = 0;
    matlfTransform.lM33 = 1;
    GpiSetDefaultViewMatrix(hps, 9, &matlfTransform, TRANSFORM_REPLACE);

    GpiMove(hps, &ptlStart);
    GpiBox(hps, DRO_OUTLINE, &ptlEnd, 0, 0); /* Draw sheared box          */


[Back: Translating, Rotating, and Scaling a Picture]
[Next: Using World to Model Space Transformations]