зеркало из https://github.com/mono/SkiaSharp.git
Added an SVG sample
This commit is contained in:
Родитель
a721759059
Коммит
456a6488ae
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
После Ширина: | Высота: | Размер: 20 KiB |
|
@ -17,5 +17,6 @@ namespace SkiaSharpSample
|
|||
ColorFilters = 1 << 8,
|
||||
ImageFilters = 1 << 9,
|
||||
PathEffects = 1 << 10,
|
||||
SVG = 1 << 11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace SkiaSharpSample
|
|||
public static Stream ColorWheel => Embedded.Load("color-wheel.png");
|
||||
public static Stream NinePatch => Embedded.Load("nine-patch.png");
|
||||
public static Stream BabyTux => Embedded.Load("baby_tux.webp");
|
||||
public static Stream LogosSvg => Embedded.Load("logos.svg");
|
||||
}
|
||||
|
||||
public static class Fonts
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace SkiaSharpSample.Samples
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
public class SvgSample : SampleBase
|
||||
{
|
||||
private SKSvg svg;
|
||||
|
||||
[Preserve]
|
||||
public SvgSample()
|
||||
{
|
||||
}
|
||||
|
||||
public override string Title => "SVG";
|
||||
|
||||
public override SampleCategories Category => SampleCategories.BitmapDecoding | SampleCategories.SVG;
|
||||
|
||||
protected override Task OnInit()
|
||||
{
|
||||
svg = new SKSvg();
|
||||
using (var stream = SampleMedia.Images.LogosSvg)
|
||||
svg.Load(stream);
|
||||
|
||||
return base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnDrawSample(SKCanvas canvas, int width, int height)
|
||||
{
|
||||
canvas.Clear(SKColors.White);
|
||||
|
||||
float canvasMin = Math.Min(width, height);
|
||||
float svgMax = Math.Max(svg.Picture.Bounds.Width, svg.Picture.Bounds.Height);
|
||||
float scale = canvasMin / svgMax;
|
||||
var matrix = SKMatrix.MakeScale(scale, scale);
|
||||
|
||||
canvas.DrawPicture(svg.Picture, ref matrix);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Samples\ManipulatedBitmapShaderSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\PathMeasureSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\PathConicToQuadsSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\SvgSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\XamagonSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\TextSample.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Samples\GradientSample.cs" />
|
||||
|
@ -64,5 +65,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="$(MSBuildThisFileDirectory)Media\content-font.ttf" />
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Media\logos.svg" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче