strokePath method

  1. @override
void strokePath(
  1. PdfPath path,
  2. PdfColor color,
  3. PdfStroke stroke,
  4. double alpha,
)
override

Implementation

@override
void strokePath(
    PdfPath path, PdfColor color, PdfStroke stroke, double alpha) {
  if (!stripsActive || delegateStrokes || _strokeOverprint) {
    _delegatePaint(() => delegateStrokePath(path, color, stroke, alpha));
    return;
  }
  if (!binningEnabled) return;
  // A stroke thinner than one device pixel is painted as a solid one-pixel
  // line, matching the canvas device (see CanvasPdfDevice's stroke floor)
  // and every reference viewer.
  //
  // This used to also scale alpha down by the sub-pixel width, reproducing
  // Skia's own behaviour for a thin stroke. That is faithful to Skia but not
  // to the page: a 0.06 pt CAD hairline came out at ~6% opacity, which is
  // the washed-out thin linework this fixes. Both paths now paint it solid.
  var deviceStroke = stroke;
  final a = alpha;
  final sf = pageToDevice.scaleFactor;
  final hairWidth = stroke.width * sf;
  if (hairWidth < 1 && sf > 0) {
    deviceStroke = stroke.copyWith(width: 1 / sf);
  }
  generator.strokePath(
      path, pageToDevice, deviceStroke, stripArgbColor(color, a),
      tolerance: stripFlattenTolerance);
}