DemaConsulting.Rendering.CanvasNet 0.3.0-beta.5

Prefix Reserved
This is a prerelease version of DemaConsulting.Rendering.CanvasNet.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DemaConsulting.Rendering.CanvasNet --version 0.3.0-beta.5
                    
NuGet\Install-Package DemaConsulting.Rendering.CanvasNet -Version 0.3.0-beta.5
                    
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="DemaConsulting.Rendering.CanvasNet" Version="0.3.0-beta.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DemaConsulting.Rendering.CanvasNet" Version="0.3.0-beta.5" />
                    
Directory.Packages.props
<PackageReference Include="DemaConsulting.Rendering.CanvasNet" />
                    
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 DemaConsulting.Rendering.CanvasNet --version 0.3.0-beta.5
                    
#r "nuget: DemaConsulting.Rendering.CanvasNet, 0.3.0-beta.5"
                    
#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 DemaConsulting.Rendering.CanvasNet@0.3.0-beta.5
                    
#: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=DemaConsulting.Rendering.CanvasNet&version=0.3.0-beta.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DemaConsulting.Rendering.CanvasNet&version=0.3.0-beta.5&prerelease
                    
Install as a Cake Tool

Rendering

GitHub forks GitHub stars GitHub contributors License Build Quality Gate Security NuGet

General-purpose diagram layout and rendering for .NET. Describe a diagram as a graph, lay it out with a pluggable algorithm, and render it to SVG, PNG, or JPEG. The design is inspired by the Eclipse Layout Kernel (ELK): layout and rendering are configured through an open, extensible property system, and new algorithms, renderers, and options are added additively.

Rendering architecture: your application, layout algorithms, renderers, and SVG, PNG, and JPEG output

Features

  • Pluggable layout algorithms — layered (Sugiyama-style), containment packing, a recursive hierarchical engine for compound (nested-container) graphs, and an auto-routing meta-algorithm that picks the best fit per connected component, each selected through the open property system. Containers hug their content, cross-container layouts do not depend on the order nodes are added in, and auto packs isolated nodes into free space, so diagrams stay compact and tidy.
  • Honored LayerSpacing — CoreOptions.LayerSpacing (default 70 px) sets the minimum corridor between layers; connectors, end markers and end labels keep whatever room they need.
  • Orthogonal edge routing — axis-aligned connectors in all four flow directions, with obstacle avoidance around intervening containers, and edges declared on an ancestor graph drawn between the actual nested nodes they reference (across container boundaries, at any nesting depth).
  • Named ports — first-class, labeled attachment points on a node's boundary, including parallel edges and per-side port labels.
  • Boundary (delegation) ports — a container port that carries both an outward external label and an inward internal label at one shared anchor, relaying an external connection into the container's nested children, with external and internal fan-out consolidated onto that single anchor.
  • Multiple output formats — SVG (zero external dependencies) plus PNG and JPEG via CanvasNet, with light, dark, and print themes.
  • SysML-ready notation primitives — SysML-agnostic building blocks for rich block diagrams: end markers including dotted triangles and the circled plus, dashed and styled boxes, centered compartment titles, in-tab folder titles, thick fork/join and terminate badges, send/accept corner icons, dashed bands, and rounded lifeline headers.
  • SysML ports and connection ends — port glyphs (direction arrows, dashed reference ports, proxy circles) with outside name : Type labels, role-name and multiplicity labels at either end of a connector, diamond boxes whose connectors anchor on the outline. These new features are opt-in: they only apply when you set a port appearance, an end label, or BoxShape.Diamond. Separately, connectors that share one face of a box now line up into straight final runs by default (Rendering#57), which changes the geometry of some existing diagrams; the gallery shows the new output.

Algorithm capabilities

The four bundled layout algorithms cover different concerns; pick auto when a diagram's shape is not known in advance, or select a leaf algorithm directly when it is. auto delegates every concern to whichever leaf algorithm it routes a component to, so its result is only as good as that leaf's own support for the row.

Concern layered containment hierarchical auto
Horizontal gap widening by edge count Yes Yes Yes Delegates
Vertical gap widening by edge count Partial No No Delegates
Container auto-expansion N/A N/A Yes Delegates
Port/label space reservation Yes No Yes Delegates
Direction/orientation support Yes No Yes Delegates
Connectivity/component awareness Yes No Yes Delegates
Aspect-ratio/canvas-shape targeting Partial Yes Partial Delegates
Nested/recursive containment handling No No Yes Delegates

See the user guide for the full capability matrix with one-line reasons per cell, the auto delegation caveats, and guidance on when to call a specific algorithm directly instead of auto.

Packages

The library is split into focused packages so consumers take only what they need:

Package Purpose
DemaConsulting.Rendering Layout model: the LayoutTree IR, the property system, and the input LayoutGraph
DemaConsulting.Rendering.Abstractions SPI: LayoutAlgorithmBase/IRenderer, registries, Theme, metrics
DemaConsulting.Rendering.Layout Layout algorithms: the layered pipeline and LayeredLayoutAlgorithm
DemaConsulting.Rendering.Svg SVG renderer with zero external dependencies
DemaConsulting.Rendering.CanvasNet CanvasNet raster renderers (PNG, JPEG) with an embedded Noto Sans font

Package dependencies form an acyclic graph: Abstractions and Layout depend on the model; Svg and CanvasNet depend on the model and Abstractions; the model depends on nothing.

Use from a Roslyn analyzer or source generator

Every package targets net8.0, net9.0, net10.0, and net11.0. The model, SPI, layout, and SVG packages additionally target netstandard2.0 with no external dependencies on that target, so a Roslyn analyzer or source generator can reference them and lay out and emit SVG diagrams at compile time. The raster package is deliberately excluded, because the CanvasNet package does not support netstandard2.0.

Installation

dotnet add package DemaConsulting.Rendering.Layout
dotnet add package DemaConsulting.Rendering.Svg

Usage

using System.IO;
using DemaConsulting.Rendering;
using DemaConsulting.Rendering.Abstractions;
using DemaConsulting.Rendering.Layout;
using DemaConsulting.Rendering.Svg;

// Describe the diagram as a graph of sized boxes and directed edges.
var graph = new LayoutGraph();
var a = graph.AddNode("a", width: 80, height: 40);
var b = graph.AddNode("b", width: 80, height: 40);
graph.AddEdge("a-b", a, b);

// Lay it out, then render the placed tree to SVG.
var tree = new LayeredLayoutAlgorithm().Apply(graph);
using var output = File.Create("diagram.svg");
new SvgRenderer().Render(tree, new RenderOptions(Themes.Light), output);

See the user guide for configuration options and extension points.

API Reference

Every package ships its full API reference as compact, AI-friendly Markdown in an api/ folder inside the NuGet package, generated from the XML documentation comments by ApiMark. Start at api/api.md (the index) and drill into the per-namespace and per-type pages for signatures, remarks, and usage examples.

A rendering gallery showcases what the library can produce — every bundled layout algorithm, orthogonal edge routing, all three themes, and both the SVG and PNG output paths. Each image is generated by the gallery test project directly from the public API, so the gallery doubles as an end-to-end rendering smoke test. Regenerate it with ./gallery.ps1.

Extensibility

  • New layout algorithms derive from LayoutAlgorithmBase and register under a new id.
  • New output formats implement IRenderer with a distinct media type.
  • New configuration options are declared as typed LayoutProperty<T> keys carried in an open property bag, so adding an option never changes an existing method signature.

Documentation

Generated documentation includes build notes, a user guide, a code quality report, requirements, requirement justifications, and a requirements-to-test trace matrix.

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup, coding standards, and the pull request process.

License

Copyright (c) DEMA Consulting. Licensed under the MIT License. See LICENSE for details.

By contributing to this project, you agree that your contributions will be licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0-beta.7 153 11/22/2026
0.3.0-beta.6 240 11/21/2026
0.3.0-beta.5 214 11/19/2026
0.3.0-beta.4 228 11/17/2026
0.3.0-beta.3 158 11/16/2026
0.3.0-beta.2 139 11/15/2026
0.3.0-beta.1 506 9/27/2026

This package embeds the Noto Sans font (SIL Open Font License 1.1, copyright Google Inc.).
CanvasNet is used for PNG and JPEG rendering (MIT license, copyright DEMA Consulting).