textPillPath function
The filled background behind a block of text, over line rects that already carry their horizontal padding on both edges.
Lines whose x-extents are within 2.5 × radius of each other snap to a
common extent; the rest meet through concave fillets.
Implementation
Path textPillPath(List<Rect> lineUsedRects) {
final rects = List<Rect>.of(lineUsedRects);
_snapNearEqual(rects);
final path = Path();
Rect? last;
for (final cur in rects) {
final radius = cur.height * 0.2;
path.addRRect(RRect.fromRectAndRadius(cur, Radius.circular(radius)));
if (last != null && (last.bottom - cur.top).abs() < 15.0) {
_addJoins(path, last, cur, radius);
}
last = cur;
}
return path;
}