MolDraw.Depiction
0.4.0
dotnet add package MolDraw.Depiction --version 0.4.0
NuGet\Install-Package MolDraw.Depiction -Version 0.4.0
<PackageReference Include="MolDraw.Depiction" Version="0.4.0" />
<PackageVersion Include="MolDraw.Depiction" Version="0.4.0" />
<PackageReference Include="MolDraw.Depiction" />
paket add MolDraw.Depiction --version 0.4.0
#r "nuget: MolDraw.Depiction, 0.4.0"
#:package MolDraw.Depiction@0.4.0
#addin nuget:?package=MolDraw.Depiction&version=0.4.0
#tool nuget:?package=MolDraw.Depiction&version=0.4.0
MolDraw.Depiction
The boundary between chemistry and rendering. An immutable, toolkit-neutral 2D depiction model
(MoleculeDepiction: atoms, bonds, rings, coordinates) plus the IChemistryEngine seam that lets any chemistry
toolkit — NCDK, RDKit, Indigo, OpenChemLib or your own code — drive the
MolDraw.Skia renderer.
No dependencies, no chemistry toolkit, no UI framework.
Install
dotnet add package MolDraw.Depiction
Targets net11.0. Dependency-free, so it is safe to reference from any layer of your app.
What you get
| Type | Purpose |
|---|---|
MoleculeDepiction |
Immutable depiction: Atoms, Bonds, Rings, Empty, GetBounds(), GetMedianBondLength() |
DepictionAtom |
Index, element symbol, 2D coordinates, implicit hydrogens, charge, mass number, label/aromatic/radical flags |
DepictionBond |
Begin/end atom, BondOrder, BondStereoDisplay (wedge/hash/wavy), DoubleBondPlacement, KekuleOrder, ring flag |
DepictionRing |
Atom indices of a ring and whether it is aromatic |
IChemistryEngine |
The seam: Name + Depict(smiles, options) → MoleculeDepiction |
DepictionBuildOptions |
Requested layout/label behaviour: ForceLayout, PerceiveAromaticity, AssignMissingWedges, CarbonLabels |
MoleculeParseException, DepictionException |
Toolkit-neutral failures — MolDraw.Maui turns them into MoleculeView.ErrorMessage |
BondOrder, BondStereoDisplay, DoubleBondPlacement, HydrogenPosition, CarbonLabelMode |
Shared enums |
Quick start: build a depiction by hand
using MolDraw.Depiction;
var depiction = new MoleculeDepiction(
[
new DepictionAtom(0, "C", 0.0, 0.0, 3, 0, null, false, HydrogenPosition.Right),
new DepictionAtom(1, "O", 1.5, 0.0, 1, 0, null, true, HydrogenPosition.Right),
],
[
new DepictionBond(0, 1, BondOrder.Single, BondStereoDisplay.None, DoubleBondPlacement.Center),
]);
Coordinates follow the MOL/RDKit convention (y points up, arbitrary bond length); the renderer scales by the median
bond length. Two hard rules are validated in the constructor: atoms[i].Index == i, bonds[j].Index == j, and every
bond must reference two distinct existing atoms. Everything else is optional and degrades gracefully (no rings → plain
bonds, no ShowLabel → skeletal formula, no Stereo → plain bonds).
Quick start: implement your own engine
using MolDraw.Depiction;
public sealed class IndigoEngine : IChemistryEngine
{
public string Name => "Indigo";
public MoleculeDepiction Depict(string smiles, DepictionBuildOptions? options = null)
{
// 1. parse `smiles` 2. lay it out 3. map the result onto DepictionAtom/DepictionBond
// throw MoleculeParseException for bad input, DepictionException when layout fails
}
}
// .NET MAUI / generic host:
builder.Services.AddSingleton<IChemistryEngine, IndigoEngine>();
That is all a UI or renderer needs — MolDraw.Maui's MoleculeView.Smiles and its depiction cache work with any engine,
and MolDraw.Skia renders the resulting MoleculeDepiction without knowing where it came from.
Related packages
| Package | Purpose |
|---|---|
| MolDraw.Depiction | this package — model + engine seam |
| MolDraw.Core | NCDK engine (AddMolDrawCore()) |
| MolDraw.Skia | SkiaSharp renderer, highlights, PNG/SVG export |
| MolDraw.Maui | .NET MAUI MoleculeView control |
Documentation
- README – full feature tour and examples
- Architecture – why the seam exists
- Changelog
- Issues
License
Apache-2.0 © Agredo Application. No third-party code is redistributed in this package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on MolDraw.Depiction:
| Package | Downloads |
|---|---|
|
MolDraw.Core
The NCDK chemistry engine for MolDraw.Net: turns SMILES, MOL and SDF input into clean 2D depictions — layout, aromaticity, ring-aware double bonds, wedge/hash stereo and implicit hydrogens. Atom indices follow the input (RDKit-compatible heavy-atom order), so per-atom model output lines up. Registers IChemistryEngine via AddMolDrawCore(); depends on NCDK (LGPL-2.1). |
|
|
MolDraw.Skia
SkiaSharp renderer for 2D chemical structures: crisp element labels, wedges, aromatic styles, light/dark presets, per-atom heat-map highlighting (Viridis, Plasma, Inferno, Magma, Turbo), colour bars, hit testing and PNG/SVG export. Works in MAUI, Avalonia, WPF or server-side .NET — no chemistry toolkit and no UI framework required. |
GitHub repositories
This package is not used by any popular GitHub repositories.