MolDraw.Skia 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MolDraw.Skia --version 0.3.0
                    
NuGet\Install-Package MolDraw.Skia -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MolDraw.Skia" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MolDraw.Skia" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="MolDraw.Skia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MolDraw.Skia --version 0.3.0
                    
#r "nuget: MolDraw.Skia, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MolDraw.Skia@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MolDraw.Skia&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=MolDraw.Skia&version=0.3.0
                    
Install as a Cake Tool

MolDraw.Skia

NuGet Downloads License: Apache-2.0

A presentation-quality SkiaSharp renderer for 2D chemical structures. Crisp element labels, wedges, aromatic styles, light/dark presets, per-atom heat-map highlighting with colour bars, hit testing for interactive apps, and PNG/SVG export. No chemistry toolkit, no UI framework — works in .NET MAUI, Avalonia, WPF, ASP.NET Core and console tools, on x64 and ARM64.

Install

dotnet add package MolDraw.Skia

Targets net10.0; depends on SkiaSharp 3.119.x and MolDraw.Depiction.

Quick start

using MolDraw.Core.Ncdk;      // optional: SMILES -> depiction (package MolDraw.Core)
using MolDraw.Skia;
using SkiaSharp;

var depiction = new DepictionBuilder().Build(new MoleculeLoader().ParseSmiles("CC(=O)OC1=CC=CC=C1C(=O)O"));

var exporter = new MoleculeImageExporter();
File.WriteAllBytes("aspirin.png", exporter.RenderPng(depiction, 400, 300, background: SKColors.White));
File.WriteAllText("aspirin.svg", exporter.RenderSvg(depiction, 400, 300));

Already have coordinates from RDKit, Indigo or a CSV? Build a MoleculeDepiction yourself and skip MolDraw.Core completely — the renderer only needs the depiction model.

Highlighting

var highlights = new MoleculeHighlights
{
    AtomWeights = weights,                       // 0..1 per atom index; NaN = no highlight
    Colormap = Colormap.Turbo,                   // Viridis (default), Plasma, Inferno, Magma, Turbo, Colormap.Custom(...)
    AtomColors = new Dictionary<int, SKColor> { [3] = SKColors.Red },     // wins over the weights
    BondColors = new Dictionary<int, SKColor> { [2] = SKColors.Orange },
    SelectedAtom = 5,
    HoveredAtom = 7,
    RadiusScale = 1.2f,
};

var png = new MoleculeImageExporter().RenderPng(depiction, 600, 400, highlights: highlights);

Highlights are drawn as soft discs/bands under bonds and labels, so the structure stays readable. Use ShowColorBar in MoleculeRenderOptions to add a scale next to the molecule.

Drawing into your own canvas

using var renderer = new MoleculeRenderer();
RenderedMolecule rendered = renderer.Render(canvas, bounds, depiction, MoleculeRenderOptions.Light, highlights);

// interactive apps: map pointer coordinates to atoms
int? atom = rendered.HitTestAtom(pointerPosition, tolerance: 4);

Works with any SKCanvas — Avalonia custom draw operations, SKSurface bitmaps, SKCanvasView in MAUI, etc.

Customisation

MoleculeRenderOptions is an immutable record; start from .Light or .Dark and use with:

var options = MoleculeRenderOptions.Dark with
{
    BondWidth = 2,
    FontSize = 16,
    FontFamily = "Segoe UI",
    MaxBondLength = 30,
    AromaticStyle = AromaticStyle.Circle,
    ShowAtomIndices = true,
    ShowColorBar = true,
    AtomColors = AtomColorScheme.CpkDark,
    BackgroundColor = SKColors.Transparent,
};

MaxBondLength caps the scale so small molecules are not blown up; fonts and lines shrink proportionally for large structures or small bounds.

Dependency injection

services.AddMolDrawSkia();     // IMoleculeRenderer + MoleculeImageExporter as singletons (stateless, thread-safe)

In a MAUI app, UseMolDraw() (from MolDraw.Maui) already does this plus UseSkiaSharp().

Package Purpose
MolDraw.Depiction model + IChemistryEngine seam
MolDraw.Core NCDK engine for SMILES/MOL/SDF input
MolDraw.Skia this package — renderer
MolDraw.Maui .NET MAUI MoleculeView control

Documentation

License

Apache-2.0 © Agredo Application. Uses SkiaSharp (MIT); the bundled colour maps are CC0 (Matplotlib) and Apache-2.0 (Google Turbo). See THIRD-PARTY-NOTICES.md.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MolDraw.Skia:

Package Downloads
MolDraw.Maui

MoleculeView — a .NET MAUI control for interactive 2D chemical structures. Bind SMILES (depicted by any registered IChemistryEngine) or a precomputed depiction, colour atoms by heat-map weights, select and hover atoms with MVVM bindings and commands, follow light/dark themes, and export the rendered structure. Contains no chemistry toolkit: add MolDraw.Core for the NCDK engine or write your own.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 109 11/18/2026
0.3.0 112 11/17/2026