Expand description
Atom-label orientation and backbone bond insets.
Caller supplies SVG-space atom coordinates. Labels split into an
atom-center part (sits on the atom) and an optional traveling
part (extends away from the molecule). OH on the left of a mol becomes
HO with O still at the atom; abbreviations like GlcA have no
traveling part — the first or last glyph is the center depending on the
bond approach side.
Orientation follows RDKit MolDraw2D (E/W/N/S). All chem scripts
(H-counts, charges, star-label markup, symbols, bold/italic) go through
crate::markup::parse_label_markup → ScriptRole fake scripts,
outlined as glyph paths, not <text>.
Structs§
- AtomIn
- Atom input for backbone + label placement.
- BondIn
- Bond as atom index pair into
place_backboneatoms slice. - BondOut
- Shortened bond endpoints in SVG space.
- Label
Parts - Atom-center glyph(s) vs optional traveling H / charge.
- Placed
Label - One placed atom label in SVG space (+Y down).
Enums§
- Label
Side - Which side the traveling text extends toward (RDKit OrientType).
Functions§
- compose_
label - Plain display string after orientation (
OH/HO/NH₂⁺). - label_
ink_ shape - Glyph ink for a placed label (halo / occupancy).
- label_
side - Orient a label from the sum of neighbor vectors (SVG +Y down).
- label_
side_ for - Like
label_sidebut degree-0 Hs-first elements use West (RDKit). - place_
backbone - Place all atom labels and shorten bond endpoints into label clearances.
- place_
label - Place one label so the atom-center glyph sits on
(atom_x, atom_y). - place_
label_ weighted - Like
place_label, with molweightincreasing bond↔label clearance. - shorten_
bond - Shorten a bond segment by end insets (same as Python
bonds.shorten). - split_
label - Split a raw label into center + traveling H + charge.