Pmad.Drawing 0.1.23

dotnet add package Pmad.Drawing --version 0.1.23
                    
NuGet\Install-Package Pmad.Drawing -Version 0.1.23
                    
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="Pmad.Drawing" Version="0.1.23" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pmad.Drawing" Version="0.1.23" />
                    
Directory.Packages.props
<PackageReference Include="Pmad.Drawing" />
                    
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 Pmad.Drawing --version 0.1.23
                    
#r "nuget: Pmad.Drawing, 0.1.23"
                    
#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 Pmad.Drawing@0.1.23
                    
#: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=Pmad.Drawing&version=0.1.23
                    
Install as a Cake Addin
#tool nuget:?package=Pmad.Drawing&version=0.1.23
                    
Install as a Cake Tool

Pmad.Drawing

NuGet License: MIT

A .NET vector drawing library that exposes a single IDrawSurface API and supports multiple output backends: SVG, PNG/WebP (via ImageSharp) and PDF (via PdfSharpCore). Tiled output for web maps (Leaflet-compatible) is also supported.

Installation

dotnet add package Pmad.Drawing

Getting started

Render to SVG

Render.ToSvg("output.svg", new Vector2D(800, 600), surface =>
{
    var fill   = new SolidColorBrush(Color.LightBlue);
    var stroke = new Pen(new SolidColorBrush(Color.DarkBlue), 2);
    var style  = surface.AllocateStyle(fill, stroke);

    surface.DrawPolygon(new[] { myPoints }, style);
    surface.DrawPolyline(myLine, style);
});

Render to PNG

Render.ToPng("output.png", new Vector2D(800, 600), surface =>
{
    // same drawing calls as SVG
});

Render to PDF

Render.ToPdf("output.pdf", new Vector2D(800, 600), surface =>
{
    // same drawing calls
});

Generate map tiles (Leaflet-compatible)

TilingInfos info = Render.ToSvgTiled(
    "tiles/map.svg",
    new Vector2D(4096, 4096),
    SvgFallBackFormats.Webp,
    drawLod1: surface => { /* full-detail drawing */ },
    drawLod2: surface => { /* reduced-detail drawing */ });

You can also tile an existing Image directly:

TilingInfos info = ImageTiler.DefaultToWebp(fullImage, "tiles/");

Drawing API overview

All output backends implement IDrawSurface:

Method Description
AllocateStyle(fill, pen) Create a reusable fill/stroke style
AllocateTextStyle(...) Create a reusable text style (font, size, colour, anchor)
AllocateIcon(size, draw) Create a reusable icon defined by a drawing callback
DrawPolygon(paths, style) Filled/stroked polygon (with holes via multiple paths)
DrawPolyline(points, style) Open polyline
DrawCircle(center, radius, style) Circle
DrawArc(center, radius, start, sweep, style) Arc
DrawTextPath(points, text, style) Text flowing along a path
DrawText(point, text, style) Text at a fixed position
DrawIcon(center, icon) Pre-allocated icon
DrawImage(image, pos, size, alpha) Raster image
DrawRoundedRectangle(tl, br, style, radius) Rounded rectangle

Brushes

Type Description
SolidColorBrush Uniform RGBA colour
VectorBrush Pattern brush defined by a drawing callback

Memory surface and scaling

MemorySurface records all drawing operations so they can be replayed at a different scale or into a different backend – useful for generating multiple zoom levels from a single drawing pass.

Output backends

Backend Class Notes
SVG SvgSurface Inline CSS styles, external image references
PNG / WebP / JPEG ImageSurface Rasterised via ImageSharp
PDF PdfSurface Single-page PDF via PdfSharpCore
Memory MemorySurface Captures operations for later replay or scaling

Dependencies

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 was computed.  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 was computed.  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 Pmad.Drawing:

Package Downloads
Pmad.Cartography.Drawing

Library for drawing maps with PDF, PNG/WEBP and SVG support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.23 130 5/5/2026
0.1.22 122 5/2/2026
0.1.20 148 1/14/2026
0.1.19 145 1/13/2026
0.1.8 398 12/15/2024