squirclePath function
Implementation
Path squirclePath(Rect rect, BorderRadius? radius) {
final c = rect.center;
double startX = rect.left;
double endX = rect.right;
double startY = rect.top;
double endY = rect.bottom;
double midX = c.dx;
double midY = c.dy;
if (radius == null) {
return new Path()
..moveTo(startX, midY)
..cubicTo(startX, startY, startX, startY, midX, startY)
..cubicTo(endX, startY, endX, startY, endX, midY)
..cubicTo(endX, endY, endX, endY, midX, endY)
..cubicTo(startX, endY, startX, endY, startX, midY)
..close();
}
return new Path()
// Start position
..moveTo(startX, startY + radius.topLeft.y)
// top left corner
..cubicTo(
startX,
startY,
startX,
startY,
startX + radius.topLeft.x,
startY,
)
// top line
..lineTo(endX - radius.topRight.x, startY)
// top right corner
..cubicTo(
endX,
startY,
endX,
startY,
endX,
startY + radius.topRight.y,
)
// right line
..lineTo(endX, endY - radius.bottomRight.y)
// bottom right corner
..cubicTo(
endX,
endY,
endX,
endY,
endX - radius.bottomRight.x,
endY,
)
// bottom line
..lineTo(startX + radius.bottomLeft.x, endY)
// bottom left corner
..cubicTo(
startX,
endY,
startX,
endY,
startX,
endY - radius.bottomLeft.y,
)
// left line
//..moveTo(startX, startY + radius)
..close();
}