summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gerber/rs274x.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py
index 2dee7cf..c5c89fb 100644
--- a/gerber/rs274x.py
+++ b/gerber/rs274x.py
@@ -88,22 +88,19 @@ class GerberFile(CamFile):
@property
def bounds(self):
- xbounds = [0.0, 0.0]
- ybounds = [0.0, 0.0]
- for stmt in [stmt for stmt in self.statements
- if isinstance(stmt, CoordStmt)]:
+ min_x = min_y = 1000000
+ max_x = max_y = -1000000
+
+ for stmt in [stmt for stmt in self.statements if isinstance(stmt, CoordStmt)]:
if stmt.x is not None:
- if stmt.x < xbounds[0]:
- xbounds[0] = stmt.x
- elif stmt.x > xbounds[1]:
- xbounds[1] = stmt.x
+ min_x = min(stmt.x, min_x)
+ max_x = max(stmt.x, max_x)
+
if stmt.y is not None:
- if stmt.y < ybounds[0]:
- ybounds[0] = stmt.y
- elif stmt.y > ybounds[1]:
- ybounds[1] = stmt.y
- return (xbounds, ybounds)
+ min_y = min(stmt.y, min_y)
+ max_y = max(stmt.y, max_y)
+ return ((min_x, max_x), (min_y, max_y))
def write(self, filename, settings=None):
""" Write data out to a gerber file