Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Rotate Text in SkiaSharp independent of Canvas (sort of....)

$
0
0

Hi

I'm wondering if anyone else has done similar to this and could share their approach to achieve this affect before I lose too much time chasing my tail!

I've got a Skia Canvas, Xamarin Native (not Forms) and I'm actually using the excellent SkiaScene plugin to handle gestures. All is working great.

Imagine a diagram in the Skia Canvas that you can pinch zoom, two finger rotation, drag around etc. Simple Nodes and Edges. This is all working fine. I'm scaling the nodes and edges paint too so the lines remain uniform as you zoom in and out. All looks good!

Anyway - I rendering text at midpoints of the lines, but obvious this text can go upside down/any angle as you use two fingers to rotate.

What I'm aiming for is to always have the text centered on the midpoint (working) and have it always render flat left to right (not working).

I know I can rotate the canvas back to 0/identity rotation to ensure text is flat, but then the positions go out of sync due to undoing any rotation/zoom/etc from the gestures.

Any thoughts? Do I have to work out the midpoints in the current canvas Matrix, and then work out where they would be in the Identity matrix setup, reset the canvas to that then draw the text at those locations...so they end up being rotated back to their correct spot (super hard to explain).

Or....is there a way to render a Paint with a custom matrix to be applied to that alone, so I can just apply an extra rotation on top of what's there to the text alone?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>