You can use saveCanvas, but you have to have a separate canvas for the graphics and one for the text, otherwise, you get an image with the text. However that was easier said than done and i have to say the API docs aren’t that great, but i got a bit stubborn and i guess it was sort of fun to play around with, also Google. I have changed some stuff but hopefully, you can still get something out of it.
Here is a Codepen you can check out.
Not sure how to attach an event listener to the save text. I added a double click and button method instead. It seems like it should be as easy as saving the text to a variable and attach the listener to it (like you can do with a canvas, an image or the button), but it didn’t seem to work, or i just failed at it.
I moved the text to the setup instead of the draw function, i have left the draw functions in but they are empty.
I use mouseClicked instead of mousePressed (unless you want to trigger on right click, but that seems like unexpected behavior to me).
I added a color picker, but it just sets the fill color for the shape.