diff options
author | jaseg <git@jaseg.de> | 2024-07-19 19:15:52 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2024-07-19 19:15:52 +0200 |
commit | d7efa577320cbb1af3d4399b008b5901309b5ea4 (patch) | |
tree | 67820c886ee48192ff44ff9873f179234dafe371 /gerbonara/utils.py | |
parent | 689ce748dba83102775871df0e49bdf615f8fe7e (diff) | |
download | gerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.tar.gz gerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.tar.bz2 gerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.zip |
kicad: Add bounding box support to lots of s-expr objects
Diffstat (limited to 'gerbonara/utils.py')
-rw-r--r-- | gerbonara/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gerbonara/utils.py b/gerbonara/utils.py index 6d8445d..fa23f52 100644 --- a/gerbonara/utils.py +++ b/gerbonara/utils.py @@ -617,3 +617,16 @@ def bbox_intersect(a, b): return x_overlap and y_overlap + +def bbox_contains(outer, inner): + if outer is None or inner is None: + return False + + (xa_min, ya_min), (xa_max, ya_max) = outer + (xb_min, yb_min), (xb_max, yb_max) = inner + + contained_x = xa_min < xb_min and xb_max < xa_max + contained_y = ya_min < yb_min and yb_max < ya_max + + return contained_x and contained_y + |