Given a list of edges, snap any within `tolerance` pixels of one another to their positional average.
(
edges,
x_tolerance=DEFAULT_SNAP_TOLERANCE,
y_tolerance=DEFAULT_SNAP_TOLERANCE,
)
| 1064 | |
| 1065 | |
| 1066 | def snap_edges( |
| 1067 | edges, |
| 1068 | x_tolerance=DEFAULT_SNAP_TOLERANCE, |
| 1069 | y_tolerance=DEFAULT_SNAP_TOLERANCE, |
| 1070 | ): |
| 1071 | """ |
| 1072 | Given a list of edges, snap any within `tolerance` pixels of one another |
| 1073 | to their positional average. |
| 1074 | """ |
| 1075 | by_orientation = {"v": [], "h": []} |
| 1076 | for e in edges: |
| 1077 | by_orientation[e["orientation"]].append(e) |
| 1078 | |
| 1079 | snapped_v = snap_objects(by_orientation["v"], "x0", x_tolerance) |
| 1080 | snapped_h = snap_objects(by_orientation["h"], "top", y_tolerance) |
| 1081 | return snapped_v + snapped_h |
| 1082 | |
| 1083 | |
| 1084 | def resize_object(obj, key: str, value): |
no test coverage detected
searching dependent graphs…