Skip to content

liwuqingxin/Avalonia.Svg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



License

This library is distributed under the MIT license.

About

📓 Avalonia.Svg is a .net rendering engine for loading and displaying Scalable Vector Graphics (SVG) files in Avalonia applications. It provides a simple way to load and render SVG files as part of your UI.

🎓 Avalonia is a cross-platform .net UI framework.

📅 This library could be also available in WPF in future, not now.

🔔 Objects generated by this rendering engine are static and non-editable.

😢 My English is not very well. Please forgive me if there are any mistakes in my expression.

❤️ Any suggestions and comments are appreciated. If you find a bug or would like to contribute to this library, please open an issue or submit a pull request on GitHub.

Using

  • About nuget: Not available now.

  • Using Icon control and it's IconSvg Property.

<controls:Icon Width="24"
               Height="24"
               IconSvg="avares://Nlnet.Avalonia.Svg.Sample/Assets/bug-fill.svg" />
  • Using Icon control and it's IconSvgData Property.
<controls:Icon ClipToBounds="{Binding #ClipToBounds.IsChecked}"
               IconStretch="Uniform"
               IconSvg="avares://Nlnet.Avalonia.Svg.Sample/Assets/NLNet.svg"
               IconSvgData="{Binding Path=EditableSvgData}"
               IsHitTestVisible="False"
               Opacity="{Binding #SvgGroundOpacity.Value}"
               ShowDiagnosis="{Binding #ShowDiagnosis.IsChecked}" />

SVG Viewer using it.

image-20230324012006442

image-20230324012210119

image-20230324012210119

image-20230324012210119

image-20230324012210119

Features

✅ The Avalonia.Svg library supports a variety of features for loading and rendering SVG files, including:

  • Loading SVG files from a svg data, svg file or a stream.
  • Resolving external resources (such as images) referenced in the SVG file.
  • Applying transformations (such as scaling, rotation, and translation) to the SVG image.
  • Setting the fill and stroke colors of the SVG image.
  • Clipping the SVG image to a specific area.

😔 While the Avalonia.Svg library supports a wide range of SVG features, there are some limitations to be aware of:

  • The library does not support all SVG elements and attributes. In particular, some advanced features (such as filters and masks) are not currently supported.

  • Animation and some other external feature of SVG are not supported, like resolving external resources (such as images) referenced in the SVG file.

  • Performance may be impacted when rendering complex SVG files with a large number of elements or gradients. We have not made any performance optimization about it till now.

📅 Pattern, masker and mark are coming soon.

Document Structure

Tag Support
svg ✔️
g ✔️
defs ✔️
symbol
use ✔️
switch
desc, title 📅
matadata 📅

✔️ Styling

We have implemented the CSS style system for SVG. We support explicit style, implicit style with selectors and local setter to set property.

✔️ Geometry Properties

We support all geometry properties include cx, ry, r, rx, ry, x, y, width, height.

✔️ Coordinate Systems, Transformations and Units

We support viewBox, transform and preserveAspectRatio properties. Note that the viewBox and preserveAspectRatio is only available in svg tag now.

✔️ Paths

Support it.

✔️ Basic Shapes

We support all basic shapes include rect, circle, ellipse, line, polyline, poligon.

📅 Text

Not yet.

❌ Embedded Content

Not yet and no plan about it.

✔️ Painting: Filling, Stroking and Marker Symbols

We have supported fill, stroke. 📅 Marker is not supported yet.

✔️ Paint Servers: Gradients and Patterns

We have supported gradients. 📅 Patterns not yet.

❌ Scripting and Interactivity

Not yet and no plan about it.

❌ Linking

Not yet and no plan about it.

Release Plan

The version 1.0.0 would come after the use and pattern being done. And then we will make a nuget package for developers.

Q&A

None.