You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have asked this before but I got a vague response. After reading the example I still could not crop the image correctly as a circle. Can anyone point what how to have a circle editor crop layer that actually crops a circle?
class CircleEditorCropLayerPainter extends EditorCropLayerPainter {
const CircleEditorCropLayerPainter();
@override
void paintCorners(
Canvas canvas, Size size, ExtendedImageCropLayerPainter painter) {
final Paint paint = Paint()
..color = painter.cornerColor
..style = PaintingStyle.fill;
final Rect cropRect = painter.cropRect;
const double radius = 6;
canvas.drawCircle(Offset(cropRect.left, cropRect.top), radius, paint);
canvas.drawCircle(Offset(cropRect.right, cropRect.top), radius, paint);
canvas.drawCircle(Offset(cropRect.left, cropRect.bottom), radius, paint);
canvas.drawCircle(Offset(cropRect.right, cropRect.bottom), radius, paint);
}
@override
void paintMask(
Canvas canvas, Size size, ExtendedImageCropLayerPainter painter) {
final Rect rect = Offset.zero & size;
final Rect cropRect = painter.cropRect;
final Color maskColor = painter.maskColor;
canvas.saveLayer(rect, Paint());
canvas.drawRect(
rect,
Paint()
..style = PaintingStyle.fill
..color = maskColor);
canvas.drawCircle(cropRect.center, cropRect.width / 2.0,
Paint()..blendMode = BlendMode.clear);
canvas.restore();
}
@override
void paintLines(
Canvas canvas, Size size, ExtendedImageCropLayerPainter painter) {
final Rect cropRect = painter.cropRect;
if (painter.pointerDown) {
canvas.save();
canvas.clipPath(Path()..addOval(cropRect));
super.paintLines(canvas, size, painter);
canvas.restore();
}
}
}
The text was updated successfully, but these errors were encountered:
I have asked this before but I got a vague response. After reading the example I still could not crop the image correctly as a circle. Can anyone point what how to have a circle editor crop layer that actually crops a circle?
The text was updated successfully, but these errors were encountered: