paintSourceAndStrokes method

void paintSourceAndStrokes(
  1. Canvas canvas
)

Paint source image + all strokes (committed + in-flight) at the current canvas origin. Caller has set up the canvas transform (e.g. camera + image-space ops); we just deposit our content. Used by both the layer's own paintViewport and by composed-scene painters that render the source × strokes pipeline inside a crop transform.

Implementation

void paintSourceAndStrokes(Canvas canvas) {
  canvas.drawImage(image, Offset.zero, Paint());
  canvas.saveLayer(Offset.zero & imageSize, Paint());
  for (var i = 0; i < strokes.length; i++) {
    final s = strokes[i];
    _paintStroke(
      canvas,
      s.points,
      s.brushType,
      _strokeColorFor(s, i),
      s.thickness,
      stroke: s,
      tailFactor: s.tailFactor,
    );
  }
  if (currentPoints.isNotEmpty) {
    _paintStroke(
      canvas,
      currentPoints,
      currentBrush,
      currentColor,
      _brushThicknessImageSpace,
      tailFactor: _activeWidthFactor,
    );
  }
  canvas.restore();
}