Rotate: Rotation around a point   [ 65 ]

Description

Performs a rotation around a given point.  All subsequent instructions will be applied as if the whole [X,Y] coordinates system has been rotated.  Typically, a Text instruction coming after a Rotate one will produce visual slanted text.  This function takes 3 float number parameters:
  1. A  ⇒  Rotation angle expressed in degrees (negative numbers supported)
  2. X  ⇒  Abscissa of the point around which rotation will take place
  3. Y  ⇒  Ordinate of the point around which rotation will take place
Developper Notes:
  • Once this function is called, rotation affects all elements which are output, with the exception of clickable areas.
  • To reset rotation, simply call this function with a zero angle.  In that case, X and Y parameters are ignored.
  • Only display is altered. GetX() and GetY() are not affected, nor the automatic page break mechanism.
  • Rotation is not kept from page to page. Each new page reset an eventual previous rotation.
  • NB: this function should be used with caution as it is sometime not that easy to anticipate Rotation effect. For instance, it may happen that text or graphic which would normally appear within an A4 page will not show after a rotation because that very rotation would have them fall beyond page boundaries.

C calling syntax
void Rotate (float angle, float x, float y)
Cobol calling syntax
CALL "Rotate" using by value ANGLE,X,Y.
C sample code
#include   "fpdf.h"

static char   f_ini ??(??) = ??< "ini??/??/demofpdf.ini" ??>;
static char   f_out ??(??) = ??< "pdf??/??/demo_b.pdf" ??>;

/* ----------------------------------------------------------------- */

int  main (int argc, char *argv [])

??<
int   ii;

NewPdfy (f_ini, 1);
AddPage ("P");
SetLineWidth (0.2);
SetFillColor (240, 240, 240);
SuperRect (10, 10, 190, 275, "DF", 1, 1, 1, 1);
SetDrawColor (16, 64, 240);
for (ii = 0; ii < 180; ii ++) {
    Rotate (ii * 2, 105, 145);
    Ellipse (105, 145, 30, 90, "D");
    }
Output (f_out);
??>
Cobol sample code
       Procedure division.
           String   'DD:FINI' Low-Value delimited by size into T0.
           String   'DD:FINI' Low-Value delimited by size into T0.
           MOVE  NB_PAGES TO I.
           CALL "NewPdfy" USING BY value Pt0, NB_PAGES.
      *
           String 'P' Low-Value delimited by size into T0.
           Call "AddPage" Using by value Pt0.
      *
           MOVE 0.2 TO LW.
           Call "SetLineWidth" Using by value LW.
      *
           MOVE 16   TO R.
           MOVE 32   TO G.
           MOVE 240 TO B.
           Call "SetFillColor" Using by value R,G,B.
           MOVE 1   TO RADIUS.
           MOVE 10   TO X.
           MOVE 10   TO Y.
           MOVE 190   TO W.
           MOVE 275   TO H.
           String  'DF' Low-Value delimited by size into T0.
           Call "SuperRect" Using by value X,Y,W,H,Pt0,RADIUS,RADIUS,RADIUS,RADIUS.
      *
           MOVE 16   TO R.
           MOVE 32   TO G.
           MOVE 240 TO B.
           Call "SetDrawColor" Using by value R,G,B.
      *
           MOVE 105 TO X.
           MOVE 145 TO Y.
           MOVE 180 TO N.
           MOVE 0 TO I.
           PERFORM UNTIL N <= 0
               COMPUTE ANGLE = I * 2
               Call "Rotate" Using by value Angle,X,Y.
               Call "Ellipse" Using by value X,Y,RX,RY,T0.
               SUBTRACT 1 FROM N
           END-PERFORM.
      *
           String  'DD:FOUT' Low-Value delimited by size into T0.
           Call "Output" Using by value Pt0.
Description of sample code
This piece of code creates an elementary rosette within a rounded corners rectangle, illustrating the use of following functions.
- SetLineWidth()  -->  Set the width of lines to be drawn
- SetDrawColor()  -->  Set the color of lines to be drawn
- SetFillColor()  -->  Set the color of area to be filled
- SuperRect()     -->  Draw a rounded corner rectangle
- Ellipse()       -->  Draw an ellipse
- Rotate()        -->  Rotate the XY coordinates of a given angle around a point 
See sample source code in 'C' as well as PDF execution result  -  NB: For encrypted PDFs, user password is USER-PSWD