SkiaSharp: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Xamarin}} ==SkiaSharp== ====Fiddles==== * [https://fiddle.skia.org/ Skia Fiddle] * [https://fiddle.skia.org/named/ Named Fiddles] ====Disposable Transform==== <syntaxhighli...") |
No edit summary |
||
Line 45: | Line 45: | ||
* [https://gist.github.com/xoofx/a9d08a37c43f692e65df80a1888c488b Resize an image and draw some overlay text with SkiaSharp] | * [https://gist.github.com/xoofx/a9d08a37c43f692e65df80a1888c488b Resize an image and draw some overlay text with SkiaSharp] | ||
====Clipping with Paths and Regions==== | |||
* [https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/clipping Clipping with Paths and Regions] | |||
====WPF==== | ====WPF==== | ||
* [https://github.com/impsnldavid/skiasharpwpfextensions skiasharpwpfextensions] | * [https://github.com/impsnldavid/skiasharpwpfextensions skiasharpwpfextensions] |
Latest revision as of 06:11, 25 March 2018
SkiaSharp
Fiddles
Disposable Transform
<syntaxhighlight lang="C#" line='line'>
using (new Transform(canvas)) {
}
public class Transform : IDisposable { private readonly SKCanvas _canvas;
public Transform(SKCanvas canvas) { _canvas = canvas; canvas.Save(); }
public void Dispose() { _canvas.Restore(); } }
</syntaxhighlight >
Transform point from current transformation matrix to original grid
<source lang="cpp">
// Transform point from current transformation matrix to original grid var originalPoints = new[] { new SKPoint(0, 0) }; var pointInCurrentTransformationMatrix = new[] { new SKPoint(0, 0) }; canvas.TotalMatrix.MapPoints(originalPoints, pointInCurrentTransformationMatrix);
// Transform point from original grid to current transformation matrix canvas.TotalMatrix.TryInvert(out var inverseMatrix); var snappedPixelPointsInCurrentTransformationMatrix = new[] { new SKPoint(0, 0) }; inverseMatrix.MapPoints(snappedPixelPointsInCurrentTransformationMatrix, originalPoints);
</source>