prepare method

  1. @override
void prepare()

Prepare the object to be written to the stream

Implementation

@override
void prepare() {
  super.prepare();

  params['/ShadingType'] = PdfNum(shadingType.index + 2);
  if (boundingBox != null) {
    params['/BBox'] = PdfArray.fromNum([
      boundingBox!.left,
      boundingBox!.bottom,
      boundingBox!.right,
      boundingBox!.top,
    ]);
  }
  params['/AntiAlias'] = const PdfBool(true);
  params['/ColorSpace'] = const PdfName('/DeviceRGB');

  if (shadingType == PdfShadingType.axial) {
    params['/Coords'] = PdfArray.fromNum([start.x, start.y, end.x, end.y]);
  } else if (shadingType == PdfShadingType.radial) {
    assert(radius0 != null);
    assert(radius1 != null);
    params['/Coords'] = PdfArray.fromNum(
        [start.x, start.y, radius0!, end.x, end.y, radius1!]);
  }
  // params['/Domain'] = PdfArray.fromNum(<num>[0, 1]);
  if (extendStart || extendEnd) {
    params['/Extend'] =
        PdfArray(<PdfBool>[PdfBool(extendStart), PdfBool(extendEnd)]);
  }
  params['/Function'] = function.ref();
}