SkiaSharp

From TurnKey+MediaWiki
Jump to navigation Jump to search

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>

Typography Line Terms.png

Clipping with Paths and Regions

WPF

id=siteTree