Check if a shape exists inside a complex shape

#1

I have a custom shape, which I made using:

        beginShape(LINES);
        vertex(190, 231);
        vertex(203, 143);
        vertex(203, 143);
        vertex(298, 153);
        vertex(298, 153);
        vertex(365, 231);
        vertex(365, 231);
        vertex(365, 413);
        vertex(365, 413);
        vertex(251, 413);
        vertex(251, 413);
        vertex(190, 231);
        endShape();

I want to check if this ellipse is inside the perimeter of this custom shape. I tried to search online and the docs but couldn’t find anything. Also, I am new to P5.js

Any help would be greatly appreciated.

Thanks.

1 Like
#2

Hi,

You might want to check this link :

1 Like
#3

You could give the shape a pale color

Then with get() check the color getColor

If it’s == shapeCol you are inside the shape

This works also with an offscreen PGraphics which allows to not use a fill color on the visible screen

#4

Here is an interactive demo of Polygon-Circle collision detection:

This example is Processing, not p5.js, but the solution is almost identical.

1 Like
#5

CrHallberg.com/CollisionDetection/Website/poly-circle.html

1 Like