2 * << Haru Free PDF Library 2.0.0 >> -- arc_demo.c
4 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation.
11 * It is provided "as is" without express or implied warranty.
20 #include "grid_sheet.h"
29 error_handler (HPDF_STATUS error_no,
30 HPDF_STATUS detail_no,
33 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no,
34 (HPDF_UINT)detail_no);
39 main (int argc, char **argv)
46 strcpy (fname, argv[0]);
47 strcat (fname, ".pdf");
49 pdf = HPDF_New (error_handler, NULL);
51 printf ("error: cannot create PdfDoc object\n");
60 /* add a new page object. */
61 page = HPDF_AddPage (pdf);
63 HPDF_Page_SetHeight (page, 220);
64 HPDF_Page_SetWidth (page, 200);
66 /* draw grid to the page */
67 print_grid (pdf, page);
78 HPDF_Page_SetRGBFill (page, 1.0, 0, 0);
79 HPDF_Page_MoveTo (page, 100, 100);
80 HPDF_Page_LineTo (page, 100, 180);
81 HPDF_Page_Arc (page, 100, 100, 80, 0, 360 * 0.45);
82 pos = HPDF_Page_GetCurrentPos (page);
83 HPDF_Page_LineTo (page, 100, 100);
84 HPDF_Page_Fill (page);
87 HPDF_Page_SetRGBFill (page, 0, 0, 1.0);
88 HPDF_Page_MoveTo (page, 100, 100);
89 HPDF_Page_LineTo (page, pos.x, pos.y);
90 HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.45, 360 * 0.7);
91 pos = HPDF_Page_GetCurrentPos (page);
92 HPDF_Page_LineTo (page, 100, 100);
93 HPDF_Page_Fill (page);
96 HPDF_Page_SetRGBFill (page, 0, 1.0, 0);
97 HPDF_Page_MoveTo (page, 100, 100);
98 HPDF_Page_LineTo (page, pos.x, pos.y);
99 HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.7, 360 * 0.85);
100 pos = HPDF_Page_GetCurrentPos (page);
101 HPDF_Page_LineTo (page, 100, 100);
102 HPDF_Page_Fill (page);
105 HPDF_Page_SetRGBFill (page, 1.0, 1.0, 0);
106 HPDF_Page_MoveTo (page, 100, 100);
107 HPDF_Page_LineTo (page, pos.x, pos.y);
108 HPDF_Page_Arc (page, 100, 100, 80, 360 * 0.85, 360);
109 pos = HPDF_Page_GetCurrentPos (page);
110 HPDF_Page_LineTo (page, 100, 100);
111 HPDF_Page_Fill (page);
113 /* draw center circle */
114 HPDF_Page_SetGrayStroke (page, 0);
115 HPDF_Page_SetGrayFill (page, 1);
116 HPDF_Page_Circle (page, 100, 100, 30);
117 HPDF_Page_Fill (page);
119 /* save the document to a file */
120 HPDF_SaveToFile (pdf, fname);