paintCorners method

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

draw crop layer corners

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;

  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);

  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);

  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);

  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);
}