Replies: 4 comments
-
The point moves because you are scaling the drawing canvas, not the view itself. For example, if you draw a point at 10,10 and then touch 10,10, you are in the correct place. But, if you scale the canvas 0.5 (50%) and draw at 10,10 - you are actually drawing at 5,5. So, if you touch at 10,10, you will be in a different place. One thing you can do is record/store the |
Beta Was this translation helpful? Give feedback.
-
I did record the TotalMatrix and it gave me but I could not get that to translate into where the view is showing the drawn rectangles where I touch. For example say my rectangle is drawn at (410, 384) dividing each of those by 2.007678 yields (208, 191) Also if I change the DPI on the Android Phone then nothing seems to be drawn in the right location. I have google and googled and googled and I cannot find anything to explain how to handle DPI Changes on the phone I also tried "IgnorePixesScaling" set to true, but that did not work either, actually made things worse. I posted this issue where I did, because no one has replied in Xamarin Help, the discussion board here, nor StackOverFlow....which makes me think.....not many people have attempted what we are trying to do? |
Beta Was this translation helpful? Give feedback.
-
您好:我已收到您的邮件,我将尽快查收处理。祝您生活愉快
|
Beta Was this translation helpful? Give feedback.
-
@sisaacks |
Beta Was this translation helpful? Give feedback.
-
First let me state, this is my first time messing with any type of drawing utility and I am way outside of my wheelhouse. First I will describe the issue I am having, then what I am trying to do and then my code.
Issue:
After scaling and transforming the canvas, when I TOUCH the canvas area on the phone, then look at the 'location' point in the touch event in Visual Studio, its not the same location that the canvas drew something. I need the exact location I drew something to show the user a popup. If directly after drawing the image I reset the matrix then the rectangles are drawn in the right location but they do not scale. I thought, well I will ResetMatrix at the very end, but that doesn't seem to matter.
What I am trying to do:
I have an image that I scale and draw to the canvas. Then I draw a large red rectangle on the image and smaller rectangles inside the larger rectangle. When the user presses the zoom button I scale by an increasing factor giving the allusion that we are zooming in on the center. So essentially the image grows in size, the large rectangle grows in size and the little rectangles grow in size. This seems to work flawlessly...but I feel I have done something wrong being that when I touch one of the little rectangles, the location is not the same (x,y) it was drawn at.
Below is most of the code I am using put all in one function for simplicity. Any help would be much appreciated. I would think the SKCanvas View would be the same coordinates as the SKCanvas but obviously I am wrong. This code will not compile because you do not have certain classes that return objects...but they do not matter....the issue is Scaling and I am not sure why
Beta Was this translation helpful? Give feedback.
All reactions