MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / _draw

Function _draw

numericals.py:1134–1188  ·  view source on GitHub ↗

Draw everything.

(
    ax: matplotlib.axes.Axes,
    points: list[gm.Point],
    lines: list[gm.Line],
    circles: list[gm.Circle],
    goal: Any,
    equals: list[tuple[Any, Any]],
    highlights: list[tuple[str, list[gm.Point]]],
)

Source from the content-addressed store, hash-verified

1132
1133
1134def _draw(
1135 ax: matplotlib.axes.Axes,
1136 points: list[gm.Point],
1137 lines: list[gm.Line],
1138 circles: list[gm.Circle],
1139 goal: Any,
1140 equals: list[tuple[Any, Any]],
1141 highlights: list[tuple[str, list[gm.Point]]],
1142):
1143 """Draw everything."""
1144 colors = ['red', 'green', 'blue', 'orange', 'magenta', 'purple']
1145 pcolor = 'black'
1146 lcolor = 'black'
1147 ccolor = 'grey'
1148 if get_theme() == 'dark':
1149 pcolor, lcolor, ccolor = 'white', 'white', 'cyan'
1150 elif get_theme() == 'light':
1151 pcolor, lcolor, ccolor = 'black', 'black', 'blue'
1152 elif get_theme() == 'grey':
1153 pcolor, lcolor, ccolor = 'black', 'black', 'grey'
1154 colors = ['grey']
1155
1156 line_boundaries = []
1157 for l in lines:
1158 p1, p2 = draw_line(ax, l, color=lcolor)
1159 line_boundaries.append((p1, p2))
1160 circles = [draw_circle(ax, c, color=ccolor) for c in circles]
1161
1162 for p in points:
1163 draw_point(ax, p.num, p.name, line_boundaries, circles, color=pcolor)
1164
1165 if equals:
1166 for i, segs in enumerate(equals['segments']):
1167 color = colors[i % len(colors)]
1168 for a, b in segs:
1169 mark_segment(ax, a, b, color, 0.5)
1170
1171 for i, angs in enumerate(equals['angles']):
1172 color = colors[i % len(colors)]
1173 for a, b, c, d in angs:
1174 highlight_angle(ax, a, b, c, d, color, 0.5)
1175
1176 if highlights:
1177 global HCOLORS
1178 if HCOLORS is None:
1179 HCOLORS = [k for k in mcolors.TABLEAU_COLORS.keys() if 'red' not in k]
1180
1181 for i, (name, args) in enumerate(highlights):
1182 color_i = HCOLORS[i % len(HCOLORS)]
1183 highlight(ax, name, args, 'black', color_i, color_i)
1184
1185 if goal:
1186 name, args = goal
1187 lcolor = color1 = color2 = 'red'
1188 highlight(ax, name, args, lcolor, color1, color2)
1189
1190
1191THEME = 'dark'

Callers 1

drawFunction · 0.85

Calls 7

get_themeFunction · 0.85
draw_lineFunction · 0.85
draw_circleFunction · 0.85
draw_pointFunction · 0.85
mark_segmentFunction · 0.85
highlight_angleFunction · 0.85
highlightFunction · 0.85

Tested by

no test coverage detected