paintCorners method

void paintCorners(
  1. Canvas canvas,
  2. Size size,
  3. ExtendedImageCropLayerPainter painter
)
inherited

Draw corners of the crop area

Implementation

void paintCorners(
  Canvas canvas,
  Size size,
  ExtendedImageCropLayerPainter painter,
) {
  final Rect cropRect = painter.cropRect;
  final Size cornerSize = painter.cornerSize;
  final double cornerWidth = cornerSize.width;
  final double cornerHeight = cornerSize.height;
  final Paint paint =
      Paint()
        ..color = painter.cornerColor
        ..style = PaintingStyle.fill;

  // Draw top-left corner
  canvas.drawPath(
    Path()
      ..moveTo(cropRect.left, cropRect.top)
      ..lineTo(cropRect.left + cornerWidth, cropRect.top)
      ..lineTo(cropRect.left + cornerWidth, cropRect.top + cornerHeight)
      ..lineTo(cropRect.left + cornerHeight, cropRect.top + cornerHeight)
      ..lineTo(cropRect.left + cornerHeight, cropRect.top + cornerWidth)
      ..lineTo(cropRect.left, cropRect.top + cornerWidth),
    paint,
  );

  // Draw bottom-left corner
  canvas.drawPath(
    Path()
      ..moveTo(cropRect.left, cropRect.bottom)
      ..lineTo(cropRect.left + cornerWidth, cropRect.bottom)
      ..lineTo(cropRect.left + cornerWidth, cropRect.bottom - cornerHeight)
      ..lineTo(cropRect.left + cornerHeight, cropRect.bottom - cornerHeight)
      ..lineTo(cropRect.left + cornerHeight, cropRect.bottom - cornerWidth)
      ..lineTo(cropRect.left, cropRect.bottom - cornerWidth),
    paint,
  );

  // Draw top-right corner
  canvas.drawPath(
    Path()
      ..moveTo(cropRect.right, cropRect.top)
      ..lineTo(cropRect.right - cornerWidth, cropRect.top)
      ..lineTo(cropRect.right - cornerWidth, cropRect.top + cornerHeight)
      ..lineTo(cropRect.right - cornerHeight, cropRect.top + cornerHeight)
      ..lineTo(cropRect.right - cornerHeight, cropRect.top + cornerWidth)
      ..lineTo(cropRect.right, cropRect.top + cornerWidth),
    paint,
  );

  // Draw bottom-right corner
  canvas.drawPath(
    Path()
      ..moveTo(cropRect.right, cropRect.bottom)
      ..lineTo(cropRect.right - cornerWidth, cropRect.bottom)
      ..lineTo(cropRect.right - cornerWidth, cropRect.bottom - cornerHeight)
      ..lineTo(cropRect.right - cornerHeight, cropRect.bottom - cornerHeight)
      ..lineTo(cropRect.right - cornerHeight, cropRect.bottom - cornerWidth)
      ..lineTo(cropRect.right, cropRect.bottom - cornerWidth),
    paint,
  );
}