(X,Y) touch coordinate after skcanvas scale and transform

196 views
Skip to first unread message

Seth Isaacks

unread,
Oct 4, 2022, 1:29:22 PM10/4/22
to skia-discuss
I am relatively new to any drawing utility. I will explain what I am doing and the result I am seeing I do not understand.  
  
What I have done:
In the PaintSurface method I am first doing a translate 
canvas.Translate(info.Width / 2f, info.Height / 2f);

// then scale and draw image
canvas.Scale(ratio);
canvas.Translate(-bounds.MidX, -bounds.MidY);
canvas.DrawPicture(svg.Picture, new SKPaint { Color = SKColors.White, Style = SKPaintStyle.Fill });

// now draw large rectangle that will also be scaled with the image
canvas.DrawRect(layout.RedBorderXOffSet, layout.RedBorderYOffSet, layout.RedBorderWidth, layout.RedBorderHeight, RedBorderPaint)

// then after this I draw smaller rectangles with in the larger rectangle giving a grid like appearance.  The rectangles are drawn at specific locations.  It works flawalessly just as I would want it too.  However when I click on one of the small rectangles I have drawns the touch event is showing a different (X,Y) than where I drew it....I mean not even near the same (X,Y) after adding in Length and Width.  I am confused as to how to get the CanvasView to have the same coordinates as the skcanvas after scaling and transforming

Any help would be much appreciated

craste...@gmail.com

unread,
Oct 5, 2022, 1:17:16 AM10/5/22
to skia-discuss
Is this about Skia in a native / C++ application?
Or in a CanvasKit / webassembly javascript application?

Seth Isaacks

unread,
Oct 5, 2022, 7:24:38 AM10/5/22
to skia-d...@googlegroups.com
C# Xamarin Mobile Application 

SUA SPONTE
-- Its better to fail while daring greatly,  than to be with those cold and timid souls who neither know victory nor defeat.
-- Someone once told me not to bite off more than I could chew. I said I'd rather choke on greatness than nibble on mediocrity. 

On Oct 4, 2022, at 22:17, craste...@gmail.com <craste...@gmail.com> wrote:

Is this about Skia in a native / C++ application?
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/91f1d7bb-8cec-4544-b3fe-9d9bbc08ebf5n%40googlegroups.com.

craste...@gmail.com

unread,
Oct 5, 2022, 10:25:41 AM10/5/22
to skia-discuss
Okay, I can't help.  I thought it might be a virtual pixel scaling problem in javascript.  But that doesn't seem to be the case for you.

Brian Osman

unread,
Oct 5, 2022, 10:28:22 AM10/5/22
to skia-d...@googlegroups.com
Most of the developers on this mailing list don't have much experience with SkiaSharp. I'd suggest posting an issue/question at https://github.com/mono/SkiaSharp/issues

Seth Isaacks

unread,
Oct 5, 2022, 10:37:23 AM10/5/22
to skia-d...@googlegroups.com
Brian...I did...no one has responded which is why I came here......github recommended that I post here

Reply all
Reply to author
Forward
0 new messages