# # This has been ported by Hiroshi Saito(hiroshi@winpg.jp) # Copyright notice of the original as below. # # * # * << Haru Free PDF Library 2.0.0 >> -- arc_demo.c # * # * Copyright (c) 1999-2006 Takeshi Kanno # * # * Permission to use, copy, modify, distribute and sell this software # * and its documentation for any purpose is hereby granted without fee, # * provided that the above copyright notice appear in all copies and # * that both that copyright notice and this permission notice appear # * in supporting documentation. # * It is provided "as is" without express or implied warranty. # * # */ @load "pdf" # --- # main # --- BEGIN { fname = "pdf_arc.pdf"; pdf = HPDF_New(NULL, NULL); # add a new page object. page = HPDF_AddPage(pdf); HPDF_Page_SetHeight(page, 220); HPDF_Page_SetWidth(page, 200); # draw pie chart # * # * A: 45% Red # * B: 25% Blue # * C: 15% green # * D: other yellow # A HPDF_Page_SetRGBFill(page, 1.0, 0, 0); HPDF_Page_MoveTo(page, 100, 100); HPDF_Page_LineTo(page, 100, 180); HPDF_Page_Arc(page, 100, 100, 80, 0, 360 * 0.45); pos = HPDF_Page_GetCurrentPos(page); # String to Number Array X, Y split(pos, posX, ","); HPDF_Page_LineTo(page, 100, 100); HPDF_Page_Fill(page); # B HPDF_Page_SetRGBFill(page, 0, 0, 1.0); HPDF_Page_MoveTo(page, 100, 100); HPDF_Page_LineTo(page, posX[1], posX[2]); HPDF_Page_Arc(page, 100, 100, 80, 360 * 0.45, 360 * 0.7); pos = HPDF_Page_GetCurrentPos(page); # String to Number Array X, Y split(pos, posX, ","); HPDF_Page_LineTo(page, 100, 100); HPDF_Page_Fill(page); # C HPDF_Page_SetRGBFill(page, 0, 1.0, 0); HPDF_Page_MoveTo(page, 100, 100); HPDF_Page_LineTo(page, posX[1], posX[2]); HPDF_Page_Arc(page, 100, 100, 80, 360 * 0.7, 360 * 0.85); pos = HPDF_Page_GetCurrentPos(page); # String to Number Array X, Y split(pos, posX, ","); HPDF_Page_LineTo(page, 100, 100); HPDF_Page_Fill(page); # D HPDF_Page_SetRGBFill(page, 1.0, 1.0, 0); HPDF_Page_MoveTo(page, 100, 100); HPDF_Page_LineTo(page, posX[1], posX[2]); HPDF_Page_Arc(page, 100, 100, 80, 360 * 0.85, 360); HPDF_Page_LineTo(page, 100, 100); HPDF_Page_Fill(page); # draw center circle HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_SetGrayFill(page, 1); HPDF_Page_Circle(page, 100, 100, 30); HPDF_Page_Fill(page); # save the document to a file HPDF_SaveToFile(pdf, fname); # clean up HPDF_Free(pdf); }