Neuerstellung

- Quelle: https://github.com/oxyplot/oxyplot
This commit is contained in:
2023-09-02 09:24:59 +02:00
commit 9520c1fa4a
810 changed files with 117869 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SvgExporter.cs" company="OxyPlot">
// Copyright (c) 2020 OxyPlot contributors
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace OxyPlot.SkiaSharp
{
using global::SkiaSharp;
using System.IO;
/// <summary>
/// Provides functionality to export plots to scalable vector graphics using the SkiaSharp SVG canvas.
/// </summary>
public class SvgExporter : IExporter
{
/// <summary>
/// Gets or sets the height (in user units) of the output area.
/// </summary>
public float Height { get; set; }
/// <summary>
/// Gets or sets the width (in user units) of the output area.
/// </summary>
public float Width { get; set; }
/// <inheritdoc/>
public void Export(IPlotModel model, Stream stream)
{
using var skStream = new SKManagedWStream(stream);
using var canvas = SKSvgCanvas.Create(new SKRect(0, 0, this.Width, this.Height), skStream);
if (!model.Background.IsInvisible())
{
canvas.Clear(model.Background.ToSKColor());
}
// SVG export does not work with UseTextShaping=true. However SVG does text shaping by itself anyway, so we can just disable it
using var context = new SkiaRenderContext { RenderTarget = RenderTarget.VectorGraphic, SkCanvas = canvas, UseTextShaping = false };
model.Update(true);
model.Render(context, new OxyRect(0, 0, this.Width, this.Height));
}
}
}