PdfFunction.fromColors constructor

PdfFunction.fromColors(
  1. PdfDocument pdfDocument,
  2. List<PdfColor?> colors
)

Implementation

factory PdfFunction.fromColors(
    PdfDocument pdfDocument, List<PdfColor?> colors) {
  final data = <int>[];
  for (final color in colors) {
    data.add((color!.red * 255.0).round() & 0xff);
    data.add((color.green * 255.0).round() & 0xff);
    data.add((color.blue * 255.0).round() & 0xff);
  }
  return PdfFunction(
    pdfDocument,
    order: 3,
    data: data,
    range: const <num>[0, 1, 0, 1, 0, 1],
  );
}