Render the slate icon at exact size with Inkscape. With inverted=False, the slate renders with its native FG body / BG stripes (right for placing on the white banner). With inverted=True, the SVG color codes are swapped before rendering so the body becomes BG and the stripes FG - ne
(inkscape: str, work_dir: Path, side: int, *, inverted: bool)
| 195 | |
| 196 | |
| 197 | def _render_slate(inkscape: str, work_dir: Path, side: int, *, inverted: bool) -> Image.Image: |
| 198 | """Render the slate icon at exact size with Inkscape. |
| 199 | |
| 200 | With inverted=False, the slate renders with its native FG body / BG stripes |
| 201 | (right for placing on the white banner). With inverted=True, the SVG color |
| 202 | codes are swapped before rendering so the body becomes BG and the stripes |
| 203 | FG - needed for the dialog's dark FG strip, where a non-inverted slate |
| 204 | would blend into the background. |
| 205 | """ |
| 206 | if inverted: |
| 207 | sentinel = "__SWAP_FG__" |
| 208 | svg_text = SLATE_SVG.read_text(encoding="utf-8") |
| 209 | svg_text = ( |
| 210 | svg_text.replace("#2a3545", sentinel) |
| 211 | .replace("#e0e8f0", "#2a3545") |
| 212 | .replace(sentinel, "#e0e8f0") |
| 213 | ) |
| 214 | svg_path = work_dir / f"slate_inv_{side}.svg" |
| 215 | svg_path.write_text(svg_text, encoding="utf-8") |
| 216 | else: |
| 217 | svg_path = SLATE_SVG |
| 218 | out = work_dir / f"slate_{'inv_' if inverted else ''}{side}.png" |
| 219 | render_svg(inkscape, svg_path, out, side, side) |
| 220 | return Image.open(out).convert("RGBA") |
| 221 | |
| 222 | |
| 223 | def _save_baseline_jpeg(img: Image.Image, path: Path) -> None: |
no test coverage detected