drawCustomRounded function
void
drawCustomRounded({})
Implementation
void drawCustomRounded({
required Path thePath,
required List<Offset> tempPos,
required List<int> order,
required int length,
required TextAlign textAlign,
required double radius,
}) {
for (var i = 0; i < order.length; i++) {
final xPos = tempPos[order[i]].dx;
final yPos = tempPos[order[i]].dy;
final theIndex = order[i];
if (theIndex == 0) {
thePath.moveTo(xPos, yPos + radius);
} else {
/// Custom Left Section
if (order.indexOf(theIndex) < length * 2) {
final xNext = tempPos[order[i + 1]].dx;
final yNext = tempPos[order[i + 1]].dy;
if (textAlign == TextAlign.left || textAlign == TextAlign.start || textAlign == TextAlign.justify) {
if (theIndex == (length * 4) - 3) {
thePath.lineTo(xPos, yPos - radius);
thePath.quadraticBezierTo(xPos, yPos, xPos + radius, yPos);
thePath.lineTo(xPos + radius, yPos);
} else {
thePath.lineTo(xPos, yPos);
}
} else {
if (xPos > xNext) {
if ((xPos - xNext).abs() < radius) {
thePath.lineTo(xPos, yNext);
} else {
thePath.lineTo(xPos, yNext - radius);
thePath.quadraticBezierTo(xPos, yNext, xPos - radius, yNext);
thePath.lineTo(xPos - radius, yNext);
}
} else if (xPos < xNext) {
if ((xPos - xNext).abs() < radius) {
thePath.lineTo(xPos, yPos - radius);
thePath.quadraticBezierTo(xPos, yPos, xPos + (xPos - xNext).abs(), yPos);
thePath.lineTo(xPos + (xPos - xNext).abs(), yPos);
} else {
thePath.lineTo(xPos, yPos - radius);
thePath.quadraticBezierTo(xPos, yPos, xPos + radius, yPos);
thePath.lineTo(xPos + radius, yPos);
}
} else if (xPos == xNext) {
final xPrev = tempPos[order[i - 1]].dx;
final yPrev = tempPos[order[i - 1]].dy;
if (xPrev > xPos) {
if ((xPrev - xPos).abs() > radius) {
thePath.lineTo(xPos + radius, yPos);
}
thePath.quadraticBezierTo(xPos, yPos, xPos, yPos + radius);
thePath.lineTo(xPos, yPos + radius);
} else {
if ((xPos - xPrev).abs() < radius) {
thePath.lineTo(xPos, yPrev);
thePath.lineTo(xPos, yPrev + radius);
} else {
thePath.lineTo(xPos - radius, yPrev);
thePath.quadraticBezierTo(xPos, yPrev, xPos, yPrev + radius);
thePath.lineTo(xPos, yPrev + radius);
}
}
}
}
} else {
/// Custom Right Section
final xPrev = tempPos[order[i - 1]].dx;
final yPrev = tempPos[order[i - 1]].dy;
if (textAlign == TextAlign.right || textAlign == TextAlign.end) {
if (theIndex == 3) {
thePath.lineTo(xPos, yPos + radius);
thePath.quadraticBezierTo(xPos, yPos, xPos - radius, yPos);
thePath.lineTo(xPos - radius, yPos);
thePath.lineTo(tempPos[order[0]].dx + radius, yPos);
thePath.quadraticBezierTo(
tempPos[order[0]].dx,
tempPos[order[0]].dy,
tempPos[order[0]].dx,
tempPos[order[0]].dy + radius,
);
} else if (theIndex == length * 4 - 2) {
thePath.lineTo(xPos - radius, yPos);
thePath.quadraticBezierTo(xPos, yPos, xPos, yPos - radius);
thePath.lineTo(xPos, yPos - radius);
} else {
thePath.lineTo(xPos, yPos);
}
} else {
if (xPos < xPrev) {
if ((xPos - xPrev).abs() < radius) {
thePath.quadraticBezierTo(xPos, yPos, xPos, yPrev - radius);
thePath.lineTo(xPos, yPos - radius);
} else {
thePath.lineTo(xPos + radius, yPrev);
thePath.quadraticBezierTo(xPos, yPrev, xPos, yPrev - radius);
thePath.lineTo(xPos, yPos - radius);
}
} else if (xPos > xPrev) {
if ((xPos - xPrev).abs() < radius) {
thePath.lineTo(xPos - (xPos - xPrev).abs(), yPos);
thePath.quadraticBezierTo(xPos, yPos, xPos, yPos - (xPos - xPrev).abs());
thePath.lineTo(xPos, yPos - (xPos - xPrev).abs());
} else {
thePath.lineTo(xPos - radius, yPos);
thePath.quadraticBezierTo(xPos, yPos, xPos, yPos - radius);
thePath.lineTo(xPos, yPos - radius);
}
} else if (xPos == xPrev && theIndex != 3) {
final xNext = tempPos[order[i] - 5].dx;
final yNext = tempPos[order[i] - 5].dy;
if (xPos < xNext) {
if ((xPos - xNext).abs() < radius) {
thePath.lineTo(xPos, yNext);
thePath.quadraticBezierTo(xPos, yNext, xNext, yNext);
thePath.lineTo(xNext, yNext);
} else {
thePath.lineTo(xPos, yNext + radius);
thePath.quadraticBezierTo(xPos, yNext, xPos + radius, yNext);
thePath.lineTo(xPos + radius, yNext);
}
} else if (xPos > xNext) {
thePath.lineTo(xPos, yPos + radius);
thePath.quadraticBezierTo(xPos, yPos, xPos - radius, yPos);
thePath.lineTo(xPos - radius, yPos);
}
} else if (theIndex == 3) {
thePath.lineTo(xPos, yPos + radius);
thePath.quadraticBezierTo(xPos, yPos, xPos - radius, yPos);
thePath.lineTo(xPos - radius, yPos);
thePath.lineTo(tempPos[order[0]].dx + radius, yPos);
thePath.quadraticBezierTo(
tempPos[order[0]].dx,
tempPos[order[0]].dy,
tempPos[order[0]].dx,
tempPos[order[0]].dy + radius,
);
}
}
}
}
}
}