Ellipse : Draw an ellipse [ 61 ]
Description
Draws an ellipse with current draw and fill colors and current line width which ought to have been previously specified by respectively SetDrawColor(), SetFillColor() and SetLineWidth(). This function takes 5 parameters described below:
- X ⇒ Float number which specifies abscissa or ellipse center
- Y ⇒ Float number which specifies ordinate or ellipse center
- RX ⇒ Float number which specifies ellipse horizontal radius
- RY ⇒ Float number which specifies ellipse vertical radius
- DF ⇒ String which specifies rendering mode:
- "D" for Draw,
- "F" for Fill,
- "DF" or "FD" for Draw and Fill
C calling syntax
void Ellipse (float x, float y, float rx, float ry, char *style)
Cobol calling syntax
CALL "Ellipse" using by value X,Y,RX,RY,STYLE.
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