Pmad.Drawing
0.1.23
dotnet add package Pmad.Drawing --version 0.1.23
NuGet\Install-Package Pmad.Drawing -Version 0.1.23
<PackageReference Include="Pmad.Drawing" Version="0.1.23" />
<PackageVersion Include="Pmad.Drawing" Version="0.1.23" />
<PackageReference Include="Pmad.Drawing" />
paket add Pmad.Drawing --version 0.1.23
#r "nuget: Pmad.Drawing, 0.1.23"
#:package Pmad.Drawing@0.1.23
#addin nuget:?package=Pmad.Drawing&version=0.1.23
#tool nuget:?package=Pmad.Drawing&version=0.1.23
Pmad.Drawing
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 |
PdfSurface |
Single-page PDF via PdfSharpCore | |
| Memory | MemorySurface |
Captures operations for later replay or scaling |
Dependencies
| Product | Versions 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. |
-
net8.0
- PdfSharpCore (>= 1.3.63)
- Pmad.Geometry (>= 0.1.46)
- Pmad.ProgressTracking (>= 0.1.28)
- SixLabors.ImageSharp (>= 3.1.11)
- SixLabors.ImageSharp.Drawing (>= 2.1.4)
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.