Check for overlapping shapes in WPF

断了今生、忘了曾经 提交于 2019-12-07 16:14:08

问题


I have a set of shapes which need to be drawn on top of each other. I need to re-order them such that the smallest shape gets drawn last (i.e. it will be closest to the user). Is there any way to check whether a shape overlappes (encloses and/or intersects) another shape. I know there is a method in Rect structure called Contains which checks whether there is an object within it. Is there a similar method or a way to simulate it on Shapes in WPF? Thanks in advance for any help.

Cheers,

Nilu


回答1:


You could probably use the Geometry.FillContainsWithDetail method. Its name is ill-chosen IMHO, but the description is clear :

Returns a value that describes the intersection between the current geometry and the specified geometry.

I have successfully used it for collision testing before, so it should work for you too...



来源:https://stackoverflow.com/questions/1388681/check-for-overlapping-shapes-in-wpf

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