Skip to content

Commit

Permalink
use math min() / max()
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Jul 20, 2023
1 parent 9d300df commit df4b205
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions lib/src/misc/private/bounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,13 @@ class Bounds<T extends num> {
var minY = double.infinity;

for (final point in points) {
if (point.x > maxX) {
maxX = point.x;
}
if (point.x < minX) {
minX = point.x;
}
if (point.y > maxY) {
maxY = point.y;
}
if (point.y < minY) {
minY = point.y;
}
maxX = math.max(point.x, maxX);
minX = math.min(point.x, minX);
maxY = math.max(point.y, maxY);
minY = math.min(point.y, minY);
}

final bounds = Bounds._(
Point(minX, minY),
Point(maxX, maxY),
);

return bounds;
return Bounds._(Point(minX, minY), Point(maxX, maxY));
}

/// Creates a new [Bounds] obtained by expanding the current ones with a new
Expand Down

0 comments on commit df4b205

Please sign in to comment.