Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
How to manipulate primitives to clip drawing objects

Example
Collapse All

Example

C++

[copy to clipboard]
PM_DOCUMENT doc = PM_DOCUMENT_New();

PM_RECT rc = {0, 0, 600, 800};
PM_PAGE page = PM_DOCUMENT_AddPage(doc, rc);
PM_CANVAS canvas = PM_PAGE_GetCanvas(page);

PM_CANVAS_SetRGBColorFill(canvas, 0.0f, 1.0f, 0.0f);
PM_CANVAS_SaveGraphicsState(canvas);
float pointX = 100.0f;
float pointY = 100.0f;
PM_CANVAS_MoveTo(canvas, pointX, pointY);

for (int i = 0; i < 5; ++i)
{
      pointX += 50 * (float)cos((i * 2 * 72 - 90) * PI / 180.0);
      pointY += 50 * (float)sin((i * 2 * 72 - 90) * PI / 180.0);
      PM_CANVAS_DrawLineTo(canvas, pointX, pointY);
}

PM_CANVAS_ClosePath(canvas);
PM_CANVAS_Clip(canvas);
PM_CANVAS_DrawRectangle(canvas, 0, 0, 150, 150, 0);
PM_CANVAS_Fill(canvas);
PM_CANVAS_RestoreGraphicsState(canvas);

pointX = 200.0f;
pointY = 200.0f;
PM_CANVAS_MoveTo(canvas, pointX, pointY);
   
for (int i = 0; i < 5; ++i)
{
      pointX += 50 * (float)cos((i * 2 * 72 - 90) * PI / 180.0);
      pointY += 50 * (float)sin((i * 2 * 72 - 90) * PI / 180.0);
      PM_CANVAS_DrawLineTo(canvas, pointX, pointY);
}

PM_CANVAS_ClosePath(canvas);
PM_CANVAS_AlternateClip(canvas);
PM_CANVAS_DrawRectangle(canvas, 150, 150, 200, 200, 0);
PM_CANVAS_Fill(canvas);
	
PM_DOCUMENT_Save(doc, "Clipping.pdf");
PM_DOCUMENT_Free(doc);

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2012, Two Pilots