setTransparency method
void
setTransparency(
- double alpha, {
- double? alphaBrush,
- PdfBlendMode mode = PdfBlendMode.normal,
Sets the transparency of this graphics.
//Creates a new PDF document.
PdfDocument doc = PdfDocument();
//Create PDF graphics for the page
doc.pages.add().graphics
//Set transparancy.
..setTransparency(0.5, alphaBrush: 0.5, mode: PdfBlendMode.hardLight)
..drawString('Hello world!',
PdfStandardFont(PdfFontFamily.helvetica, 12, style: PdfFontStyle.bold),
brush: PdfBrushes.red, pen: PdfPens.black);
//Saves the document.
List<int> bytes = doc.save();
//Dispose the document.
doc.dispose();
Implementation
void setTransparency(double alpha,
{double? alphaBrush, PdfBlendMode mode = PdfBlendMode.normal}) {
if (alpha < 0 || alpha > 1) {
ArgumentError.value(alpha, 'alpha', 'invalid alpha value');
}
alphaBrush ??= alpha;
_helper.applyTransparency(alpha, alphaBrush, mode);
}