Draw everything on the same canvas.
(
points: list[gm.Point],
lines: list[gm.Line],
circles: list[gm.Circle],
segments: list[gm.Segment],
goal: Any = None,
highlights: list[tuple[str, list[gm.Point]]] = None,
equals: list[tuple[Any, Any]] = None,
block: bool = True,
save_to: str = None,
theme: str = 'dark',
)
| 1201 | |
| 1202 | |
| 1203 | def draw( |
| 1204 | points: list[gm.Point], |
| 1205 | lines: list[gm.Line], |
| 1206 | circles: list[gm.Circle], |
| 1207 | segments: list[gm.Segment], |
| 1208 | goal: Any = None, |
| 1209 | highlights: list[tuple[str, list[gm.Point]]] = None, |
| 1210 | equals: list[tuple[Any, Any]] = None, |
| 1211 | block: bool = True, |
| 1212 | save_to: str = None, |
| 1213 | theme: str = 'dark', |
| 1214 | ) -> None: |
| 1215 | """Draw everything on the same canvas.""" |
| 1216 | plt.close() |
| 1217 | imsize = 512 / 100 |
| 1218 | fig, ax = plt.subplots(figsize=(imsize, imsize), dpi=100) |
| 1219 | |
| 1220 | set_theme(theme) |
| 1221 | |
| 1222 | if get_theme() == 'dark': |
| 1223 | ax.set_facecolor((0.0, 0.0, 0.0)) |
| 1224 | else: |
| 1225 | ax.set_facecolor((1.0, 1.0, 1.0)) |
| 1226 | |
| 1227 | _draw(ax, points, lines, circles, goal, equals, highlights) |
| 1228 | |
| 1229 | plt.axis('equal') |
| 1230 | fig.subplots_adjust(left=0, right=1, top=1, bottom=0, wspace=0, hspace=0) |
| 1231 | if points: |
| 1232 | xmin = min([p.num.x for p in points]) |
| 1233 | xmax = max([p.num.x for p in points]) |
| 1234 | ymin = min([p.num.y for p in points]) |
| 1235 | ymax = max([p.num.y for p in points]) |
| 1236 | plt.margins((xmax - xmin) * 0.1, (ymax - ymin) * 0.1) |
| 1237 | |
| 1238 | plt.show(block=block) |
| 1239 | |
| 1240 | |
| 1241 | def close_enough(a: float, b: float, tol: float = 1e-12) -> bool: |