SharpAstro.Svg
3.35.1841
See the version list below for details.
dotnet add package SharpAstro.Svg --version 3.35.1841
NuGet\Install-Package SharpAstro.Svg -Version 3.35.1841
<PackageReference Include="SharpAstro.Svg" Version="3.35.1841" />
<PackageVersion Include="SharpAstro.Svg" Version="3.35.1841" />
<PackageReference Include="SharpAstro.Svg" />
paket add SharpAstro.Svg --version 3.35.1841
#r "nuget: SharpAstro.Svg, 3.35.1841"
#:package SharpAstro.Svg@3.35.1841
#addin nuget:?package=SharpAstro.Svg&version=3.35.1841
#tool nuget:?package=SharpAstro.Svg&version=3.35.1841
SharpAstro.Svg
Reads an SVG document into a resolved SharpAstro.Vector.VectorScene. It does not draw: there is no
rasteriser and no font code in this package, and it is not part of the SharpAstro.Codecs pixel facade.
The caller renders the scene with whatever it has.
SvgDocument document = SvgReader.Read(File.ReadAllBytes("drawing.svg")); // .svg or .svgz
VectorScene scene = document.Scene; // pixels at 96 to the inch, viewBox already applied
foreach (SvgIssue issue in document.Issues) // everything the scene leaves out
Console.WriteLine($"{issue.Kind}: {issue.What} x{issue.Count}");
Written from the W3C SVG 1.1 and SVG 2 specifications.
What is read
- The root's
width,height,viewBoxandpreserveAspectRatio. ganda;path(every command, arcs included),rect,circle,ellipse,line,polyline,polygon.transform(matrix, translate, scale, rotate, skewX, skewY).- Solid
fillandstroke: hex,rgb(),hsl(), named colours,currentColor;fill-rule;fill-opacity,stroke-opacity,opacity;stroke-width,-linecap,-linejoin,-miterlimit,-dasharray,-dashoffset. displayandvisibility; presentation attributes and thestyleattribute, inherited as CSS says.- Lengths in px, pt, pc, mm, cm, in, Q, em, ex (taken as half an em) and %.
In the scene every path is absolute move / line / quad / cubic / close (arcs and circles become cubics), every transform is multiplied out onto its shape, and a group appears only where opacity needs a layer.
What is not read yet
Each of these is left out of the scene and reported in SvgDocument.Issues
(SvgReadOptions.ThrowOnUnsupported makes the first one an exception):
- gradients and patterns (the fallback colour after
url(...)is used, or nothing) use,symbol, nestedsvg,switch,image,text,foreignObjectclip-path,mask,filter, markers,mix-blend-mode,paint-order,vector-effect<style>sheets andclassselectors,transformwritten as a CSS property, animation
XML entities are not expanded and nothing outside the document is fetched; a document that relies on an entity
it declares itself (some Adobe Illustrator exports do) is refused with InvalidDataException.
Limits
SvgReadOptions bounds the characters of XML (after gzip), the element count, the nesting depth and the total
number of path segments. With nothing here that can repeat content (use is not read), a scene's size is
proportional to the document's.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- SharpAstro.Vector (>= 3.35.1841)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on SharpAstro.Svg:
| Package | Downloads |
|---|---|
|
DIR.Lib
Device-Independent input and Rendering library for .NET: surface-neutral drawing primitives, an immutable layout DSL, a widget toolkit, font rasterization (bitmap + SDF) and font fallback, shared by GPU (SDL3 + Vulkan), terminal and browser (WebGL2 / Blazor WebAssembly) front ends. Pure managed, AOT compatible, no native dependencies. |
|
|
SharpAstro.Fonts
Pure-managed, MIT-licensed C# OpenType / TrueType font loader and rasterizer. |
|
|
DIR.Lib.Debug
The Debug build of DIR.Lib, for Debug consumers that need the #if DEBUG types the Release DIR.Lib package does not contain (the inspector core itself is in the Release package since 11.70, off unless DIR_INSPECTOR=1 and DIR_INSPECTOR_TOKEN are set). Same version as DIR.Lib. Reference DIR.Lib when the configuration is not Debug and DIR.Lib.Debug when it is, with a Configuration-conditioned PackageReference; Visual Studio needs a restore after switching configuration. |
GitHub repositories
This package is not used by any popular GitHub repositories.