FluentSvg 1.0.0
dotnet add package FluentSvg --version 1.0.0
NuGet\Install-Package FluentSvg -Version 1.0.0
<PackageReference Include="FluentSvg" Version="1.0.0" />
<PackageVersion Include="FluentSvg" Version="1.0.0" />
<PackageReference Include="FluentSvg" />
paket add FluentSvg --version 1.0.0
#r "nuget: FluentSvg, 1.0.0"
#:package FluentSvg@1.0.0
#addin nuget:?package=FluentSvg&version=1.0.0
#tool nuget:?package=FluentSvg&version=1.0.0
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
Gallery
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(withSetCornerRadiusfor rounded rects),AddLine,AddPolygon,AddPolyline. - Paths —
AddPath(...)(many overloads, including integerVector2Ipoints) for polylines, andAddPathBuilder()for a fluent path with curves:LineTo,CubicTo,SmoothCubicTo,QuadTo,SmoothQuadTo,ArcTo,Close.Svg.DecodePath(d)parses an SVGdstring (M/L/H/V/Z) back into point lists. - Text —
AddTextwith 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>, plusAddSvg()for nested<svg>. - Animation — SMIL:
AddAnimate,AddAnimateXy,AddAnimateLine, and transforms viaAddAnimateTransform/AddAnimateTranslate/AddAnimateRotate(withadditiveso translate + rotate compose). - Styling — fluent extension methods:
SetFill,SetStroke,SetStrokeWidth,SetStrokeDashArray,SetFontSize,SetFillOpacity,RotateAroundPoint, etc. (also acceptSystem.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 scratchbob.svgin the system temp directory — handy for quick "dump and look at it" debugging.
License
MIT
| 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
- 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 |