Skip to content

Rust

Crate Role
xpict Public API + RDKit layout (needs system RDKit + Boost)
xpict-core Shared paint only (no RDKit) — used by WASM / PyO3
xpict = "0.1"
# or paint-only:
xpict-core = "0.1"

Single molecule

use xpict::{mol, MolRenderOptions};

let mut benzene = mol("c1ccccc1")?;
let rendered = benzene.render(MolRenderOptions {
    color: Some("#0b6e4f".into()),
    atom_shade: Some(vec![0.0, 0.0, 0.2, 0.0, 0.0, 0.9]),
    star_labels: Some(vec![Some("$R_1$".into())]), // when source has *
    ..Default::default()
})?;
let svg = rendered.to_svg();
Benzene colored
`color`
Star R₁
`star_labels`

Declarative document

use xpict::{depict, DepictSpec, MolNode};

let out = depict(&DepictSpec::Group {
    id: None,
    children: vec![
        MolNode {
            smiles: Some("CCO".into()),
            color: Some("#0b6e4f".into()),
            ..Default::default()
        },
        MolNode {
            cxsmiles: Some("*c1ccccc1Cl |$R1;;;;;$|".into()),
            ..Default::default()
        },
    ],
})?;
let svg = out[0].to_svg();
Ethanol with shading
Ethanol
Markush
CX on a mol node