1 file changed, +22, -21
2c9601dstyle(render): rename variables to be more informative
render/pixels.py
+22, -21
+22, -21
@@ -155,21 +155,22 @@ def render_maze(
155155 Returns:
156156 Multi-line string with a trailing newline.
157157 """
158 - cs = PLAIN if pure_ascii else BG
159 - idx = color_idx % len(cs.palette)
160 - ec, xc = cs.entry[idx], cs.exit_[idx]
161 - dc = cs.dark[idx]
162 - pc = cs.path[idx]
163 - vc = cs.visited[idx]
164 - bgc = cs.bg[idx]
158+ colors = PLAIN if pure_ascii else BG
159+ theme = color_idx % len(colors.palette)
160+ entry_color = colors.entry[theme]
161+ exit_color = colors.exit_[theme]
162+ glyph_color = colors.dark[theme]
163+ path_color = colors.path[theme]
164+ visited_color = colors.visited[theme]
165+ bg_color = colors.bg[theme]
165166 kind_color: dict[str, str] = {
166 - _WALL: cs.palette[idx],
167 - _GLYPH: dc,
168 - _PATH: pc,
169 - _VISITED: vc,
170 - _BG: bgc,
167+ _WALL: colors.palette[theme],
168+ _GLYPH: glyph_color,
169+ _PATH: path_color,
170+ _VISITED: visited_color,
171+ _BG: bg_color,
171172 }
172 - rs = "" if pure_ascii else RESET
173+ reset = "" if pure_ascii else RESET
173174 glyphs = _ASCII_GLYPHS if pure_ascii else _BLOCK_GLYPHS
174175
175176 if path_steps is not None:
@@ -218,20 +219,20 @@ def render_maze(
218219
219220 def _mark(color: str, ascii_glyph: str) -> str:
220221 """Wrap a glyph in color; use PIXEL block unless pure_ascii."""
221 - return color + (ascii_glyph if pure_ascii else PIXEL) + rs
222+ return color + (ascii_glyph if pure_ascii else PIXEL) + reset
222223
223224 px, py = _cell_to_pixel(*pos)
224225 if pos in pattern:
225 - return _mark(dc, "##")
226+ return _mark(glyph_color, "##")
226227 if pos == gen.entry:
227 - return _mark(ec, "E ")
228+ return _mark(entry_color, "E ")
228229 if pos == gen.exit_:
229 - return _mark(xc, "X ")
230+ return _mark(exit_color, "X ")
230231 if (px, py) in path_px:
231 - return _mark(pc, "..")
232+ return _mark(path_color, "..")
232233 if visited_cells is not None and pos in visited_cells:
233 - return _mark(vc, "~~")
234 - return bgc + PIXEL + rs
234+ return _mark(visited_color, "~~")
235+ return _mark(bg_color, " ")
235236
236237 def _emit(px: int, py: int) -> str:
237238 """Render one pixel-grid cell."""
@@ -240,7 +241,7 @@ def render_maze(
240241 return _cell_marker((px // 2, py // 2))
241242 parity = _parity(px, py)
242243 glyph = glyphs.get((kind, parity), glyphs[(_BG, parity)])
243 - return kind_color[kind] + glyph + rs
244+ return kind_color[kind] + glyph + reset
244245
245246 lines: list[str] = [
246247 "".join(_emit(px, py) for px in range(cols * 2 + 1))