chematic-depict
2D molecular structure depiction as SVG. Ring templates, wedge/dash stereo bonds, CPK coloring, and automatic layout. Pure Rust, no C/C++ dependencies, WASM-compatible.
Features
- SVG output: vector graphics suitable for web and print
- Ring templates: pre-drawn benzene and other common rings for cleaner depiction
- Stereo bonds: wedge (Up) and dash (Down) for 3D stereochemistry
- CPK coloring: element-specific color scheme (C gray, H white, O red, N blue, etc.)
- Automatic 2D layout: uses distance geometry and spring forces for readable coordinates
- Atom/bond highlighting: highlight arbitrary atoms or bonds with color overlays
- Label customization: hide/show atom symbols, hydrogens, or atom indices
- WASM-compatible: zero C/C++ dependencies
Quick Start
use parse;
use depict_smiles;
let mol = parse.expect;
let svg = depict_smiles.expect;
println!; // Print SVG to stdout or write to file
API Overview
Main Functions
depict_smiles(smiles: &str, options: &DepictOptions) -> Result<String, DepictError>— SVG from SMILESdepict_molecule(mol: &Molecule, options: &DepictOptions) -> String— SVG from Moleculedepict_reaction(rxn_smiles: &str, options: &RenderOptions) -> Result<String, RenderError>— reaction scheme SVG
Configuration
use DepictOptions;
let opts = DepictOptions ;
let svg = depict_molecule;
Output Example
For benzene (c1ccccc1):
<!-- regular hexagon with C atoms at vertices -->
<!-- bonds connecting each vertex -->
Dependencies
chematic-core— molecular graphchematic-smiles— SMILES parserchematic-perception— 2D coordinate generation
References
- SVG spec: https://www.w3.org/TR/SVG2/
- CPK coloring: https://en.wikipedia.org/wiki/CPK_coloring
See Also
chematic— main umbrella cratechematic-3d— 3D structure generation and visualizationchematic-smiles— SMILES parser