Method to 'fill' a non rectangular shape with a pattern

I want to fill a non-rectangular shape with a pattern.

Filling a rectangular shape is not a problem… all I need to do is to find the top left, bottom right coordinates and then not exceed them in my loop placing the pattern elements.

Filling a circle should also be fairly straightforward, find the centre but do not exceed the radius… but I’m struggling to think how I could do this with a different shape, for example a star?

Does anyone know of a way to identify a shape and use it as some kind of mask?

Conversely, is it possible to flip this idea and fill everything outside of a shape.

Thank you in advance…

Hello @GoodJuJu,

A related topic:

I modified code above to have 2 PGraphics and did this:



The resources here will have more details:



1 Like

I am so sorry I didn’t reply sooner… thank you so much for your help.

The links you sent were really useful :slight_smile:

1 Like