paintWithPattern method

void paintWithPattern(
  1. Canvas canvas,
  2. double x,
  3. double y,
  4. double width,
  5. double height,
)
override

After clipping the canvas to the shape we want, paint the Pattern on the rectangle defined by the provided x, y, width, height.

Implementation

void paintWithPattern(
    Canvas canvas, double x, double y, double width, double height) {
  final stripesCount = featuresCount * 2;
  final stripeH = height / stripesCount / 6;
  final paint = Paint()
    ..style = PaintingStyle.fill
    ..color = bgColor;
  canvas.drawRect(Rect.fromLTWH(x, y, width, height), paint);
  var dy = 0.0;
  final rectsPath = Path();
  for (var i = 0; i < stripesCount; i++) {
    final rect = Rect.fromLTWH(x, y + dy + stripeH, width, stripeH);
    rectsPath.addRect(rect);
    dy += stripeH * 12;
  }
  paint
    ..style = PaintingStyle.fill
    ..color = fgColor;
  canvas.drawPath(rectsPath, paint);
}