xpict¶
Molecule depiction for publication-quality SVG — one Rust paint core, with RDKit layout at each language edge (Python, JavaScript/WASM, native Rust).
Two first-class APIs share the same paint:
| API | Shape | Good for |
|---|---|---|
| Single molecule | mol → render → toSvg |
One structure, options, align_to |
| Declarative document | nested JSON (type: "mol" / group) |
Batches and a document model that is still expanding |
Single molecule¶
Build a mol, render with options, turn the scene into SVG.
import { xpict } from "@xenosite/xpict";
const benzene = xpict.mol("c1ccccc1");
const rendered = await xpict.render(benzene, {
color: "#0b6e4f",
atom_shade: [0, 0, 0.2, 0, 0, 0.9],
});
const svg = xpict.toSvg(rendered.scene);
// Align a second mol onto the first pose
const aligned = await xpict.render(xpict.mol("Cc1ccccc1"), {
align_to: benzene, // or align_to: rendered
});
Star / Markush labels on this path use star_labels (chem markup OK) or a
CXSMILES trailer when star_labels is omitted:
Label markup · full option table in API overview.
Declarative document¶
Nested JSON — a strict subset of future PictSpec. Fields today are
structure, id, color, shade, and star_labels. Richer diagram nodes stay
under xpict.future until they graduate; every document must still validate as
future PictSpec.
const [r] = await xpict.depict({
type: "mol",
smiles: "CCO",
color: "#0b6e4f",
shade: { atoms: [0.0, 0.2, 0.9], vmin: 0, vmax: 1 },
});
const svg = xpict.toSvg(r.scene);
const batch = await xpict.depict({
type: "group",
children: [
{ type: "mol", smiles: "*c1ccccc1Cl", star_labels: ["$R_1$"] },
{ type: "mol", smiles: "c1ccccc1O" },
],
});
More depictions¶
Packages¶
| Language | Package | Docs |
|---|---|---|
| Python | xpict |
API |
| JavaScript | @xenosite/xpict |
API |
| Rust | xpict / xpict-core |
API |