Drawing editable and selectable shapes with Win2D?

这一生的挚爱 提交于 2019-12-04 13:33:12

Win2D can help you with hit-testing. With geometries that have a fill color, then use CanvasGeometry.FillContainsPoint(...) and for geometries that only have an outline/stroke, use CanvasGeometry.StrokeContainsPoint(...). Using these two methods, you'll get accurate hit-testing. Using bounds is not accurate for non-rectangular shapes, including rotated rectangles.

For z-indexing, then you have to keep track of the order of your geometries and go through the list from top to bottom until the PointerPoint has hit something.

If your list of geometries is too large and you notice a lag, then you can start hit-testing using bounds first and if it fails, continue to next item, if it hits, then use the above methods to get an accurate reading.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!