Question

I have a canvas with zoom (ScaleTransform). Now I have scaled the canvas by some arbitrary zoom value. I'm adding RectangleGeomtry at the MouseDown Point with every MouseDown event. But the strange thing is the Shape is getting added to the canvas with some +/-dx and +/-dy to the MouseDown Point.

Any leads on why this happening is much appreciated.

Was it helpful?

Solution

In a scaled canvas, you should get an inverse transform (Scale and Translate) of the point and then apply transform (Scale and Translate) after constructing geometry. It worked. I am not sure if that's the best way.

OTHER TIPS

When you apply a scale transform all points get transformed (moved). For instance if you have point A(10,20) and you apply a scale of 2 to the image your point A will now be A(20,40). When you want to add a point to a scaled image you must adjust the coordinates like that ... (multiply by scale)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top