Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 78

Previous Page 77   Index   Next Page 79

Transparency
Page 78 of 770
pdfSetPageCoords(PDF, pcTopDown);
TPDFExtGState gs;
pdfInitExtGState(&gs);
gs.FillAlpha = 0.5f;
SI32 gs1 = pdfCreateExtGState(PDF, &gs);
gs.FillAlpha = 1.0f;
SI32 gs2 = pdfCreateExtGState(PDF, &gs);
double x = 150.0;
double y = 150.0;
pdfAppend(PDF);
pdfSetExtGState(PDF, gs1); // Apply the extended graphics state
pdfSetFillColor(PDF, PDF_RGB(255, 0, 0));
pdfDrawCircle(PDF, x, y, 50.0, fmFill);
pdfSetFillColor(PDF, PDF_RGB(0, 255, 0));
pdfDrawCircle(PDF, x + 75.0, y, 50.0, fmFill);
pdfSetFillColor(PDF, PDF_RGB(0, 0, 255));
pdfDrawCircle(PDF, x + 37.5, y + 50.0, 50.0, fmFill);
// Restore the fill alpha to fully opaque
pdfSetExtGState(PDF, gs2);
x += 200.0;
pdfSetFillColor(PDF, PDF_RGB(255, 0, 0));
pdfDrawCircle(PDF, x, y, 50.0, fmFill);
pdfSetFillColor(PDF, PDF_RGB(0, 255, 0));
pdfDrawCircle(PDF, x + 75.0, y, 50.0, fmFill);
pdfSetFillColor(PDF, PDF_RGB(0, 0, 255));
pdfDrawCircle(PDF, x + 37.5, y + 50.0, 50.0, fmFill);
pdfEndPage(PDF);
return pdfCloseFile(PDF);
}
Output:
 

Previous topic: PDF Transparency, Alpha Blending

Next topic: Transparency Groups / Soft Masks