flatten method Null safety

PdfColor flatten(
  1. {PdfColor background = const PdfColor(1, 1, 1)}
)

Apply the color transparency by updating the color values according to a background color.

Implementation

PdfColor flatten({PdfColor background = const PdfColor(1, 1, 1)}) {
  return PdfColor(
    alpha * red + (1 - alpha) * background.red,
    alpha * green + (1 - alpha) * background.green,
    alpha * blue + (1 - alpha) * background.blue,
    background.alpha,
  );
}