Logic to find an object under cursor in screen
I want to know general logic to find a screen object under a point.
Let there be various shapes on screen and I want to find a shape(or sh开发者_JS百科apes) on some point, probably the mouse cursor point. If all those shapes are rectangles, it'll be a trivial question. But what about triangles and ovals and...
In other words, what is the general logic behind any gui systems which find out which object is clicked or under cursor? Or, what is the logic behind any games which find out which character is clicked or under cursor?
Probably this kind of question was asked before, but I couldn't find.
edit) At least I want to know the pixel-based 2D algorithm. I found there's Point-in-polygon problem, but it's not about ovals and other irregular shapes.
That's a bit broad... the general logic, would be to use the API of whatever you're interfacing with.
This would vary depending on what indeed it is you're dealing with - the general logic is going to be completely different for a 3D application compared to a 2D windowing system. Again, if you're dealing with a 2D application is this application full screen, so you only have to consider absolute X,Y values - or is it under a windowing system in which case you care more about X,Y in relation to the window as opposed to the entire screen.
精彩评论