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.

有帮助吗?

解决方案

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.

其他提示

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)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top