trace method
Iterates over the points along the edge of the Rect.
Implementation
Iterable<Vec> trace() {
if (width > 1 && height > 1) {
// TODO(bob): Implement an iterator class here if building the list is
// slow.
// Trace all four sides.
final result = <Vec>[];
for (var x = left; x < right; x++) {
result.add(Vec(x, top));
result.add(Vec(x, bottom - 1));
}
for (var y = top + 1; y < bottom - 1; y++) {
result.add(Vec(left, y));
result.add(Vec(right - 1, y));
}
return result;
} else if (width > 1 && height == 1) {
// A single row.
return Rect.row(left, top, width);
} else if (height >= 1 && width == 1) {
// A single column, or one unit
return Rect.column(left, top, height);
}
// Otherwise, the rect doesn't have a positive size, so there's nothing to
// trace.
return const [];
}