How to check whether mouse is inside curve vertex?

Hi, i'm making an interactive video for my school project where the user can make choices by clicking objects on the end frame of a video. I'm doing this in p5.js, I didn't put it in that sub category because I feel that the answer to my question will also be helpful for normal processing.

What I want to do is outline the shape (of a person for example) with a closed curve vertex and then test to see if mouse is clicked inside that area. I really have no idea how to this for complex shapes such as a curve vertex! Any help would be much appreciated!

Thank you, Manu

Tagged:

Answers

  • in classic processing you could use a hidden canvas with same size as the visible canvas

    on the hidden canvas you make everything in color (e.g. background black, person red) and then use get to get the color and if it's red you are in the shape.

  • You should split the problem into 2 parts

    I want to do is outline the shape (of a person for example) with a closed curve vertex

    then test to see if mouse is clicked inside that area

    Do you know how to do the first part because if you can't recreate the shape with curved lines then the second part is irrelevant.

    If I was to do this myself I would approximate the shape with straight lines ie a closed polygon. By controlling the length of the sides you can ensure an acceptable level of accuracy. It is a simple algorithm to determine if a point is inside a polygon.

Sign In or Register to comment.