All Projects → wieslawsoltes → Svg.skia

wieslawsoltes / Svg.skia

Licence: mit
An SVG rendering library.

Projects that are alternatives of or similar to Svg.skia

Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (+68.03%)
Mutual labels:  graphics, rendering, 2d, vector-graphics, svg
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (+13.93%)
Mutual labels:  graphics, rendering, vector-graphics, svg
Plutovg
Tiny 2D vector graphics library in C
Stars: ✭ 141 (+15.57%)
Mutual labels:  vector, graphics, 2d, svg
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (+24.59%)
Mutual labels:  graphics, rendering, 2d, svg
Gg
Go Graphics - 2D rendering in Go with a simple API.
Stars: ✭ 3,162 (+2491.8%)
Mutual labels:  graphics, rendering, 2d
Graphics32
Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.
Stars: ✭ 238 (+95.08%)
Mutual labels:  graphics, 2d, vector-graphics
Vectorlogozone
3,000+ gorgeous SVG logos, perfect for your README or credits page
Stars: ✭ 239 (+95.9%)
Mutual labels:  vector, vector-graphics, svg
3dtilesrendererjs
Renderer for 3D Tiles in Javascript using three.js
Stars: ✭ 333 (+172.95%)
Mutual labels:  graphics, rendering, geometry
ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (-82.79%)
Mutual labels:  geometry, vector, vector-graphics
Touchdesigner shared
TouchDesigner toxes and small projects
Stars: ✭ 385 (+215.57%)
Mutual labels:  graphics, rendering, geometry
Zrender
A lightweight graphic library providing 2d draw for Apache ECharts
Stars: ✭ 5,122 (+4098.36%)
Mutual labels:  2d, vector-graphics, svg
Scour
Scour - An SVG Optimizer / Cleaner
Stars: ✭ 443 (+263.11%)
Mutual labels:  graphics, vector-graphics, svg
Macsvg
macSVG - An open-source macOS app for designing HTML5 SVG (Scalable Vector Graphics) art and animation with a WebKit web view ➤➤➤
Stars: ✭ 789 (+546.72%)
Mutual labels:  graphics, vector-graphics, svg
Gerbolyze
Render high-resolution bitmap images to PCB gerber files
Stars: ✭ 169 (+38.52%)
Mutual labels:  graphics, vector-graphics, svg
Synfig
This is the Official source code repository of the Synfig project
Stars: ✭ 1,056 (+765.57%)
Mutual labels:  vector, 2d, vector-graphics
Php Svg
Vector graphics (SVG) library for PHP
Stars: ✭ 256 (+109.84%)
Mutual labels:  rendering, vector-graphics, svg
Pts
A library for visualization and creative-coding
Stars: ✭ 4,628 (+3693.44%)
Mutual labels:  vector, graphics, svg
Sophus
C++ implementation of Lie Groups using Eigen.
Stars: ✭ 1,048 (+759.02%)
Mutual labels:  graphics, 2d, geometry
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+871.31%)
Mutual labels:  vector, geometry, svg
Citro2d
Library for drawing 2D graphics using the Nintendo 3DS's PICA200 GPU
Stars: ✭ 88 (-27.87%)
Mutual labels:  graphics, 2d

Svg.Skia

Gitter

Build status CI

NuGet NuGet MyGet

GitHub release Github All Releases Github Releases

Svg.Skia is an SVG rendering library.

About

Svg.Skia can be used as a .NET library or as a CLI application to render SVG files based on a static SVG Full 1.1 subset to raster images or to a backend's canvas.

The Svg.Skia is using SVG library to load Svg object model.

The Svg.Skia library is implemented using SkiaSharp rendering backend that aims to be on par or more complete then original System.Drawing implementation and more performant and cross-platform.

The Svg.Skia can be used in same way as the SkiaSharp.Extended.Svg (load svg files as SKPicture).

The Svg library has more complete implementation of Svg document model then SkiaSharp.Extended.Svg and the Svg.Skia renderer will provide more complete rendering subsystem implementation.

NuGet

Svg.Skia is delivered as a NuGet package.

You can find the packages here NuGet and install the package like this:

Install-Package Svg.Skia

or by using nightly build feed:

  • Add https://www.myget.org/F/svgskia-nightly/api/v2 to your package sources
  • Alternative nightly build feed https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json
  • Update your package using Svg.Skia feed

and install the package like this:

Install-Package Svg.Skia -Pre

Usage

Library

Install Package

dotnet add package Svg.Skia
Install-Package Svg.Skia

Draw on Canvas

using SkiaSharp;
using Svg.Skia;

var svg = new SKSvg();

svg.Load("image.svg");

SKCanvas canvas = ...
canvas.DrawPicture(svg.Picture);

Save as Png

using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svg") is { })
    {
        svg.Save("image.png", SKEncodedImageFormat.Png, 100, 1f, 1f);
    }
}
using System.IO;
using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svg") is { })
    {
        using (var stream = File.OpenWrite("image.png"))
        {
            svg.Picture.ToImage(stream, SKColors.Empty, SKEncodedImageFormat.Png, 100, 1f, 1f);
        }
    }
}
using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svgz") is { })
    {
        svg.Save("image.png", SKEncodedImageFormat.Png, 100, 1f, 1f);
    }
}
using System.IO;
using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svgz") is { })
    {
        using (var stream = File.OpenWrite("image.png"))
        {
            svg.Picture.ToImage(stream, SKColors.Empty, SKEncodedImageFormat.Png, 100, 1f, 1f);
        }
    }
}

Save as Pdf

using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svg") is { })
    {
        svg.Picture.ToPdf("image.pdf", SKColors.Empty, 1f, 1f);
    }
}

Save as Xps

using SkiaSharp;
using Svg.Skia;

using (var svg = new SKSvg())
{
    if (svg.Load("image.svg") is { })
    {
        svg.Picture.ToXps("image.xps", SKColors.Empty, 1f, 1f);
    }
}

AvaloniaUI

Install Package

dotnet add package Avalonia.Svg.Skia
Install-Package Avalonia.Svg.Skia

Add namespace to XAML

<UseControl xmlns="https://github.com/avaloniaui"
            xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia">

Set Image.Source

<Image>
   <Image.Source>
       <svg:SvgImage Source="/Assets/__AJ_Digital_Camera.svg"/>
   </Image.Source>
</Image>

Use Resources

<UserControl.Resources>
    <svg:SvgImage x:Key="__tiger" Source="/Assets/__tiger.svg"/>
</UserControl.Resources>
<Image Name="svgResourceImage" Source="{DynamicResource __tiger}"/>

Tool

dotnet tool install -g Svg.Skia.Converter
Svg.Skia.Converter:
  Converts a svg file to an encoded bitmap image.

Usage:
  Svg.Skia.Converter [options]

Options:
  -f, --inputFiles <inputfiles>              The relative or absolute path to the input files
  -d, --inputDirectory <inputdirectory>      The relative or absolute path to the input directory
  -o, --outputDirectory <outputdirectory>    The relative or absolute path to the output directory
  --outputFiles <outputfiles>                The relative or absolute path to the output files
  -p, --pattern <pattern>                    The search string to match against the names of files in the input directory
  --format <format>                          The output image format
  -q, --quality <quality>                    The output image quality
  -b, --background <background>              The output image background
  -s, --scale <scale>                        The output image horizontal and vertical scaling factor
  --scaleX, -sx <scalex>                     The output image horizontal scaling factor
  --scaleY, -sy <scaley>                     The output image vertical scaling factor
  --systemLanguage <systemlanguage>          The system language name as defined in BCP 47
  --quiet                                    Set verbosity level to quiet
  -c, --load-config <load-config>            The relative or absolute path to the config file
  --save-config <save-config>                The relative or absolute path to the config file
  --version                                  Show version information
  -?, -h, --help                             Show help and usage information

Supported formats: png, jpg, jpeg, webp, pdf, xps

SVG to C# Compiler

About

SVGC compiles SVG drawing markup to C# using SkiaSharp as rendering engine. SVGC can be also used as codegen for upcoming C# 9 Source Generator feature.

Demo

Source Generator Usage

Add NuGet package reference to your csproj.

<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>net5.0</TargetFramework>
  <LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
  <PackageReference Include="Svg.SourceGenerator.Skia" Version="0.5.0" />
</ItemGroup>

Include svg assets file in your csproj.

<ItemGroup>
  <AdditionalFiles Include="Assets/Sample.svg" NamespaceName="Assets" ClassName="Sample" />
</ItemGroup>

Use generated SKPicture using static Picture property from Sample class.

using SkiaSharp;
using Assets;

public void Draw(SKCanvas canvas)
{
    canvas.DrawPicture(Sample.Picture);
}

Avalonia Usage

csproj

<ItemGroup>
  <AdditionalFiles Include="Assets/__tiger.svg" NamespaceName="AvaloniaSample" ClassName="Tiger" />
</ItemGroup>
<ItemGroup>
  <PackageReference Include="Svg.SourceGenerator.Skia" Version="0.5.0" />
  <PackageReference Include="Avalonia.SKPictureImage" Version="0.5.0" />
</ItemGroup>

xaml

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AvaloniaSample;assembly=AvaloniaSample"
        xmlns:skp="clr-namespace:Avalonia.SKPictureImage;assembly=Avalonia.SKPictureImage"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        Width="900" Height="650" WindowStartupLocation="CenterScreen"
        x:Class="AvaloniaSample.MainWindow"
        Title="AvaloniaSample">
    <Window.Resources>
        <skp:SKPictureImage x:Key="TigeImage" Source="{x:Static local:Tiger.Picture}" />
    </Window.Resources>
    <Grid>
        <Image Source="{StaticResource TigeImage}" />
    </Grid>
</Window>

svgc Usage

svgc:
  Converts a svg file to a C# code.

Usage:
  svgc [options]

Options:
  -i, --inputFile <inputfile>      The relative or absolute path to the input file [default: ]
  -o, --outputFile <outputfile>    The relative or absolute path to the output file [default: ]
  -j, --jsonFile <jsonfile>        The relative or absolute path to the json file [default: ]
  -n, --namespace <namespace>      The generated C# namespace name [default: Svg]
  -c, --class <class>              The generated C# class name [default: Generated]
  --version                        Show version information
  -?, -h, --help                   Show help and usage information

Json File Format

[
    { "InputFile":"file1.svg", "OutputFile":"file1.svg.cs", "Class":"ClassName1", "Namespace":"NamespaceName" },
    { "InputFile":"file2.svg", "OutputFile":"file2.svg.cs", "Class":"ClassName2", "Namespace":"NamespaceName" }
]

Links

Build

To build the projects you need to install .NET 5.0 version SDK 5.0.100.

git clone [email protected]:wieslawsoltes/Svg.Skia.git
cd Svg.Skia
git submodule update --init --recursive
dotnet build -c Release

Publish Managed

cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r win7-x64 /p:PublishTrimmed=True /p:PublishReadyToRun=True -o Svg.Skia.Converter_net5.0_win7-x64
cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r ubuntu.14.04-x64 /p:PublishTrimmed=True /p:PublishReadyToRun=True -o Svg.Skia.Converter_net5.0_ubuntu.14.04-x64
cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r osx.10.12-x64 /p:PublishTrimmed=True /p:PublishReadyToRun=True -o Svg.Skia.Converter_net5.0_osx.10.12-x64
cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r debian.8-x64 /p:PublishTrimmed=True /p:PublishReadyToRun=True -o Svg.Skia.Converter_net5.0_debian.8-x64
cd ./src/SvgToPng
dotnet publish -c Release -f net5.0 -r win7-x64 -o SvgToPng_net5.0_win7-x64
cd ./src/SvgToPng
dotnet publish -c Release -f net461 -r win7-x64 -o SvgToPng_net461_win7-x64
cd ./src/SvgXml.Diagnostics
dotnet publish -c Release -f net5.0 -r win7-x64 -o SvgXml.Diagnostics_net5.0_win7-x64

Publish Native

cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r win-x64 -o Svg.Skia.Converter_net5.0_win-x64
cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r linux-x64 -o Svg.Skia.Converter_net5.0_linux-x64
cd ./src/Svg.Skia.Converter
dotnet publish -c Release -f net5.0 -r osx-x64 -o Svg.Skia.Converter_net5.0_osx-x64

Externals

The Svg.Skia library is using code from the https://github.com/vvvv/SVG

License

Parts of Svg.Skia source code are adapted from the https://github.com/vvvv/SVG

Svg.Skia is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].