diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-02-20 13:57:19 -0200 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-02-20 13:58:08 -0200 |
commit | 5d764a68908bf905741f91e01c1250b5b64edc52 (patch) | |
tree | 95bc13c1c2c82d24b0ead602f08cc755af194917 /gerber/rs274x.py | |
parent | d830375c4c33e6a863e02c9f767c127841a070f7 (diff) | |
download | gerbonara-5d764a68908bf905741f91e01c1250b5b64edc52.tar.gz gerbonara-5d764a68908bf905741f91e01c1250b5b64edc52.tar.bz2 gerbonara-5d764a68908bf905741f91e01c1250b5b64edc52.zip |
Fix GerberFile.bounds when board origin is negative
Diffstat (limited to 'gerber/rs274x.py')
-rw-r--r-- | gerber/rs274x.py | 23 |
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 |