paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Paints the shape on the given canvas.

This method must be implemented by all concrete shape painters. It should handle the actual drawing logic for the specific shape.

canvas is the canvas to paint on. size is the size of the canvas.

Implementation

@override
void paint(Canvas canvas, Size size) {
  final paint = Paint()
    ..color = color
    ..style = PaintingStyle.fill;

  if (repeatPattern) {
    // Draw dots in a grid pattern
    for (double x = patternOffset.dx; x < size.width; x += spacing) {
      for (double y = patternOffset.dy; y < size.height; y += spacing) {
        canvas.drawCircle(Offset(x, y), dotSize / 2, paint);
      }
    }
  } else {
    // Draw a single dot at the center
    final center = Offset(size.width / 2, size.height / 2);
    canvas.drawCircle(center, dotSize / 2, paint);
  }
}