docs: add a script and README for the block icons - #121
Merged
Merged
Conversation
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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
| Duplication | 0 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of the untracked-file cleanup in #45.
visjac_p.pngandestpose_p.pngwere generated withbdtex2icon(a bdsim console script) from an untrackedicons.sh, which also needs LaTeX and the unpublishedrvc-notationmacros (\\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 matplotlibmathtext(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_imagesaves 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.pypasses (2 tests). Only this test file was run, not the full suite; no library code changed.Checklist
🤖 Generated with Claude Code