Ways to Erase Part of a Line? (Preserve background)

In Setup I’ve got a gradient being applied to the entire canvas.
In Draw, I’m drawing some lines using a wide strokeWeight. I’d like to be able to erase part of the line and have the gradient below show through. Is there a way to erase only the line and not the underlying background that was drawn in Setup?

I haven’t tried yet, but I’m thinking I might be able to use createCanvas to draw the lines on a second canvas and erase them there.

1 Like

You can store the background in setup as PImage using get and show it as a background

Instead of deleting from the line can’t you draw the
2 parts separately?

What I’m doing is drawing lines with a wide strokeWidth and then erasing parts of the line, for example a shape cut out of one edge of the line.

As in this example, creating the letter ‘B’ from lines and attempting to erase a triangular shape on the right edge, but the erase function erases the background too.

I decided to use createGraphics and draw the lines (and erasures) on a second canvas on top of the original canvas with the gradient. This works.

2 Likes

Sorry, I was offline.

Good job!