DynaPDF Manual - Page 73
Previous Page 72 Index Next Page 74
Path Painting and Construction
Page 73 of 839
If we change the draw direction of the second rectangle to ddClockwise (default is
ddCounterClockwise) then we get the same result as with Even Odd:
pdfSetFillColor(pdf, PDF_RGB(120, 120, 220));
pdfRectangle(pdf, 50.0, 50.0, 250.0, 100.0, fmNoFill);
pdfSetDrawDirection(pdf, ddClockwise); // Change the draw direction
pdfRectangle(pdf, 70.0, 70.0, 210.0, 60.0, fmNoFill);
pdfClosePath(pdf, fmFill); // Non-Zero Winding Number
Output:
Winding (fmFill):
Even Odd (fmFillEvOdd):
The filling rules work also with clipping paths and more complex paths:
#include "dynapdf.h"
// First we declare our error callback function
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
{
printf("%s\n", ErrMessage); return 0;
}
void DrawPath(const void* PDF, double x, double y, TClippingMode Mode,
TDrawDirection Direction, UI32 Color)
{
pdfSaveGraphicState(PDF);
pdfSetFillColor(PDF, Color);
pdfTriangle(PDF, x+100, y+50, x+150, y+150, x+50, y+150, fmNoFill);
pdfSetDrawDirection(PDF, Direction);
pdfTriangle(PDF, x+100, y+180, x+50, y+80, x+150, y+80, fmNoFill);
pdfClipPath(PDF, Mode, fmFillStroke);
pdfSetFont(PDF, "Arial", fsBold | fsItalic, 40, true, cp1252);
pdfSetFillColor(PDF, 0);
pdfWriteText(PDF, x+50, y+90, "CLIPPING");
pdfRestoreGraphicState(PDF);
}
int main(int argc, char* argv[])
{
void* pdf = pdfNewPDF();
if (!pdf) return 2;
Previous topic: Even-Odd Rule
Next topic: Color Spaces, Device Color Spaces