FluentSvg 1.0.0

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

FluentSvg

A minimal, dependency-free fluent builder for generating SVG documents in .NET.

It does one thing: let you assemble an SVG out of shapes, paths, text, clip paths and SMIL animations with a small fluent API, then render it to a string or a file. No third-party dependencies — points are plain System.Numerics.Vector2.

dotnet add package FluentSvg

All of these are real SVGs generated by samples/Gallery and most are animated — open them to see the motion (the stills below loop in a browser).

<p align="center"> <img src="gallery/car.svg" width="440" alt="A car steering around a track"><br> <em>A car defined once as a <code><symbol></code>, then driven with <code>AddAnimateTranslate</code> + <code>AddAnimateRotate</code> so it steers to face its heading.</em> </p>

<p align="center"> <img src="gallery/orbits.svg" width="220" alt="Planets orbiting a sun"> <img src="gallery/wave.svg" width="220" alt="A travelling sine wave"> <img src="gallery/pulse.svg" width="220" alt="Pulsing rings"> </p>

<p align="center"> <em>Orbits (<code>AddAnimateXy</code>) · a wave (<code>AddAnimateLine</code>) · pulsing rings (animating <code>r</code> / <code>stroke-opacity</code>).</em> </p>

<p align="center"> <img src="gallery/curves.svg" width="330" alt="Bezier and arc curves"> <img src="gallery/clips.svg" width="330" alt="Clip paths"> </p>

<p align="center"> <em>Curves via <code>AddPathBuilder</code> (cubic / quadratic / arc) · clip paths.</em> </p>

<p align="center"><img src="gallery/primitives.svg" width="460" alt="Static primitives showcase"></p>

Regenerate them with:

dotnet run --project samples/Gallery -- gallery

Quick start

using System.Numerics;
using FluentSvg;

var svg = new Svg("hello.svg", title: "Demo");

svg.AddRectangleFromTo(new Vector2(0, 0), new Vector2(100, 60))
   .SetFill("CornflowerBlue")
   .SetStroke("navy", 2);

svg.AddCircle(new Vector2(50, 30), 20).SetFill("white");

svg.AddText(new Vector2(50, 30), "Hi").Center().SetFill("black");

svg.SaveToFile();              // writes hello.svg next to the working directory

Prefer the markup as a string?

string xml = new Svg("ignored.svg").AddCircle(new Vector2(10, 10), 5).Svg.Render();

What's in the box

  • Shapes — AddCircle, AddEllipse, AddRectangleFromTo / AddRectangleSized / AddRectangleCenterSized (with SetCornerRadius for rounded rects), AddLine, AddPolygon, AddPolyline.
  • Paths — AddPath(...) (many overloads, including integer Vector2I points) for polylines, and AddPathBuilder() for a fluent path with curves: LineTo, CubicTo, SmoothCubicTo, QuadTo, SmoothQuadTo, ArcTo, Close. Svg.DecodePath(d) parses an SVG d string (M/L/H/V/Z) back into point lists.
  • Text — AddText with a full set of alignment helpers (Center, AlignTopLeft, AlignBottomCenter, ...). Text and attribute values are XML-escaped.
  • Clip paths — rectangle, triangle, and "everything except this triangle" variants.
  • Reuse — AddSymbol(id) + AddUse(id, pos) to define once and stamp many.
  • Grouping — PushGroup() / PopGroup() to wrap items in <g>, plus AddSvg() for nested <svg>.
  • Animation — SMIL: AddAnimate, AddAnimateXy, AddAnimateLine, and transforms via AddAnimateTransform / AddAnimateTranslate / AddAnimateRotate (with additive so translate + rotate compose).
  • Styling — fluent extension methods: SetFill, SetStroke, SetStrokeWidth, SetStrokeDashArray, SetFontSize, SetFillOpacity, RotateAroundPoint, etc. (also accept System.Drawing.Color).

The view box and width/height are computed automatically from the geometry's extents (plus a configurable Margin); pass an explicit size to the constructor to override.

Notes

  • Output is well-formed: text/attribute content is XML-escaped (& < > " ').
  • All numeric formatting is invariant-culture, so output is stable regardless of locale.
  • Svg.Bob(...) is a convenience factory that targets a scratch bob.svg in the system temp directory — handy for quick "dump and look at it" debugging.

License

MIT

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.
  • net8.0

    • No dependencies.

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
1.0.0 162 7/1/2026