SharpAstro.Svg
3.36.1891
See the version list below for details.
dotnet add package SharpAstro.Svg --version 3.36.1891
NuGet\Install-Package SharpAstro.Svg -Version 3.36.1891
<PackageReference Include="SharpAstro.Svg" Version="3.36.1891" />
<PackageVersion Include="SharpAstro.Svg" Version="3.36.1891" />
<PackageReference Include="SharpAstro.Svg" />
paket add SharpAstro.Svg --version 3.36.1891
#r "nuget: SharpAstro.Svg, 3.36.1891"
#:package SharpAstro.Svg@3.36.1891
#addin nuget:?package=SharpAstro.Svg&version=3.36.1891
#tool nuget:?package=SharpAstro.Svg&version=3.36.1891
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, and held against a headless browser.
What is read
- The root's
width,height,viewBoxandpreserveAspectRatio; nestedsvgas a viewport of its own. ganda;path(every command, arcs included),rect,circle,ellipse,line,polyline,polygon.defs,use(withhreforxlink:href) andsymbol.transform(matrix, translate, scale, rotate, skewX, skewY).fillandstroke: colours (hex,rgb(),hsl(), names,currentColor),linearGradientandradialGradient(bounding-box and user-space units,gradientTransform,spreadMethod, focal point and radius, stops withstop-color/stop-opacity, inheritance throughhref), with a fallback colour.fill-rule;fill-opacity,stroke-opacity,opacity;stroke-width,-linecap,-linejoin,-miterlimit,-dasharray,-dashoffset;display,visibility.- Presentation attributes, the
styleattribute and<style>sheets, cascaded 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, every use is expanded (instances of one path share one
VectorPath), a gradient is a paint with its own transform into the shape's coordinates, and a group appears
only where opacity needs a layer.
Style sheets
Selectors are built from a type or *, .class, #id, [attr] and [attr=value] (also ~=, |=, ^=,
$=, *=), :first-child, :last-child, :only-child, :root and :link, joined by the descendant, child
(>), next-sibling (+) and later-sibling (~) combinators. Specificity, source order and !important are
honoured. :hover and the like never match. @media rules with plain media types are decided (screen and
all apply). Any other selector or at-rule that could change the picture is reported and left out.
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):
patternpaints (the fallback colour afterurl(...)is used, or nothing)image,text,switch,foreignObjectclip-path,mask,filter, markers,mix-blend-mode,paint-order,vector-effect- the clip a nested
svgor asymbolputs round its content, reported only when content really reaches outside it - references to other documents;
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 elements, the nesting depth, the path segments
and the selector tests the style sheets cost. use can make a small document describe a very large drawing, so
elements, depth and path segments are counted for every instance a use makes: forty lines of nested use
elements asking for 2^40 rectangles are refused when the count passes MaxElements.
| 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.36.1891)
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.