SkiaSharp

From Yggenyk
Revision as of 06:08, 25 March 2018 by WikiSysop (talk | contribs) (Created page with "{{Xamarin}} ==SkiaSharp== ====Fiddles==== * [https://fiddle.skia.org/ Skia Fiddle] * [https://fiddle.skia.org/named/ Named Fiddles] ====Disposable Transform==== <syntaxhighli...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

WPF

id=siteTree