Merged
Conversation
…lems with bond positions next
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
This PR adds a new
chemdrawrendering preset and associated renderer changes to approximate a Chemdraw-style 2D line diagram, while reusing xyzrender’s existing graph and SVG pipeline.chemdrawpreset that removes atom circles, draws uniform thin bonds, and labels non‑carbon atoms with bold element symbols.Details
Preset and configuration
src/xyzrender/presets/chemdraw.json:chemdraw_style: trueto toggle Chemdraw-specific behaviour in the renderer.bond_widthtuned for line diagrams).label_font_sizefor legible element symbols.RenderConfigwith:chemdraw_style: bool = False(default off), set from presets/JSON via the existing config machinery.Atom rendering (Chemdraw mode)
render_svg:cfg.chemdraw_styleisTrue:blend_fog) for consistent depth fading.#000000) to stay visible on light backgrounds.cfg.show_indices) remains unchanged and is only active when explicitly requested.Bond rendering and placement
Bond endpoints:
max(original_radius, k * label_font_size / scale)(with an empirical factor), so the bond endpoint moves further away from the atom as labels get larger, reducing overlap with text.Uniform thickness:
bond_width * 0.6), independent of bond order. This keeps the visual style consistent.Aromatic bonds (special handling):
(px, py)andgap.Documentation and examples
README.md:examples/images/caffeine_chemdraw.svg.examples/images/caffeine_chemdraw.svgandexamples/images/bimp_chemdraw.svggenerated with the new preset.Future work / known limitations
This PR focuses on the core Chemdraw-like look (hidden C–H, labelled heteroatoms, uniform thin bonds, aromatic styling, CPK-coloured labels). There are still several refinements that could be tackled in follow-up PRs:
Double/triple bond layout:
More precise label–bond interaction:
Additional presets / variations:
I’m happy to iterate on any of these in subsequent PRs if you’d like to refine the Chemdraw style further.