Skip to content

docs: add a script and README for the block icons - #121

Merged
petercorke merged 2 commits into
mainfrom
docs/icons-make-script
Oct 3, 2026
Merged

petercorke merged 2 commits into
mainfrom
docs/icons-make-script

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Part of the untracked-file cleanup in #45. visjac_p.png and estpose_p.png were generated with bdtex2icon (a bdsim console script) from an untracked icons.sh, which also needs LaTeX and the unpublished rvc-notation macros (\\mat, \\pose). Nothing in the repo said how the icons were made.

Adds, in blocks/Icons/:

  • make_icons.py: renders TeX math to a 250x250 black-on-transparent RGBA PNG using matplotlib mathtext (Computer Modern) and Pillow, which are already dependencies, so no LaTeX and no bdsim. Entries are written with the macros expanded (\\mathbf{J}_p, \\xi(p, P)). python make_icons.py [name ...] [--outdir DIR].
  • README.md: the icon convention (shared with bdsim's Icons folder) and how to add an icon.
  • tests/test_make_icons.py: size, mode, black ink, clear border, small ink coverage, anti-aliasing, and an error for malformed TeX.

The existing icon PNGs are not regenerated. The new rendering has the same glyphs but slightly different size and placement (checked visually against the originals composited on a colored background; not pixel-identical).

A bug the tests caught

mathtext.math_to_image saves a matplotlib figure, so its output is black ink on an opaque white background, not transparent. My first version pasted it as-is, so the icons were white squares that only looked right on a white viewer. A first test passed it anyway; the final test also requires a transparent border and that ink covers under 40% of the icon, and I confirmed it fails against a variant that produces a solid opaque square. The script now derives alpha from darkness (ink is black) and keeps RGB at zero.

Verification

Clean venvs for OpenCV 4.14 and 5.0: tests/test_make_icons.py passes (2 tests). Only this test file was run, not the full suite; no library code changed.

Checklist

  • PR title follows Conventional Commits
  • Added tests for this change
  • CI green

🤖 Generated with Claude Code

The bdtex2icon commands that made visjac_p.png and estpose_p.png were only
in an untracked icons.sh, and need bdsim, LaTeX and the (unpublished)
rvc-notation macros. Add make_icons.py, which renders TeX math to the same
250x250 black-on-transparent RGBA icons with matplotlib mathtext, so no new
dependency and no LaTeX install is needed, and a README describing the
convention (shared with bdsim's Icons folder).

The existing icon PNGs are not regenerated.

Adds tests/test_make_icons.py. Its checks include that the border is
transparent and ink covers a small fraction of the icon: an early version of
the script produced an opaque white-backed square (math_to_image saves a
figure with an opaque background) and a weaker test let it through.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 12 complexity · 0 duplication

Metric Results
Complexity 12
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 1185da9 into main Oct 3, 2026
37 checks passed
@petercorke
petercorke deleted the docs/icons-make-script branch October 3, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant