paintLines method

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

draw crop layer lines

Implementation

void paintLines(
    Canvas canvas, Size size, ExtendedImageCropLayerPainter painter) {
  final Color lineColor = painter.lineColor;
  final double lineHeight = painter.lineHeight;
  final Rect cropRect = painter.cropRect;
  final bool pointerDown = painter.pointerDown;
  final Paint linePainter = Paint()
    ..color = lineColor
    ..strokeWidth = lineHeight
    ..style = PaintingStyle.stroke;
  canvas.drawRect(cropRect, linePainter);

  if (pointerDown) {
    canvas.drawLine(
        Offset((cropRect.right - cropRect.left) / 3.0 + cropRect.left,
            cropRect.top),
        Offset((cropRect.right - cropRect.left) / 3.0 + cropRect.left,
            cropRect.bottom),
        linePainter);

    canvas.drawLine(
        Offset((cropRect.right - cropRect.left) / 3.0 * 2.0 + cropRect.left,
            cropRect.top),
        Offset((cropRect.right - cropRect.left) / 3.0 * 2.0 + cropRect.left,
            cropRect.bottom),
        linePainter);

    canvas.drawLine(
        Offset(
          cropRect.left,
          (cropRect.bottom - cropRect.top) / 3.0 + cropRect.top,
        ),
        Offset(
          cropRect.right,
          (cropRect.bottom - cropRect.top) / 3.0 + cropRect.top,
        ),
        linePainter);

    canvas.drawLine(
        Offset(cropRect.left,
            (cropRect.bottom - cropRect.top) / 3.0 * 2.0 + cropRect.top),
        Offset(
          cropRect.right,
          (cropRect.bottom - cropRect.top) / 3.0 * 2.0 + cropRect.top,
        ),
        linePainter);
  }
}