w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to detect if a point is on the boundary( i.e 'edges') of a shape

you have 2 coordinates of the shape position.

shape.X
shape.Y

you have also the size of the shape

shape.Height
shape.Width

You have the coordinates of the mouse position

mouse.X
mouse.Y

If mouse.X is between shape.X and shape.X+shape.Width and mouse.Y is equal to shape.Y or shape.Y+shape.Heigh and so on for a rectangle

For different but "regular" shapes you should calculate it in a similarway

For complex and irregular shape you should discompose it to smal pieces and do the same calculation:

check this: determine if a point sits inside an arbitrary shape?

If the shape can be converted to a bitmap another way could be to check for pixel color but this will work only if the shape edge color are different from other pixel in the shape





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.