r/processing • u/snapkarklepop • 14d ago
Help request drawing program
i’m creating a drawing program within processing and i’m trying to add a way to change the background/canvas color. within the draw function, i have a color wheel that changes the brush color, as well as a color wheel that changes the canvas color. all is going smoothly, except when i try to put it all together. if i draw the canvas within the void setup, the user is unable to change its color. however, if i draw the canvas within the void draw, it redraws itself between every iteration of the brushstroke, so the brush only ever shows up at its current state and never leaves a mark behind.
i think i worded this oddly but hopefully it makes sense. can anybody help me figure out how to allow the canvas color to change while not “erasing” the brush strokes?
View all comments
3
u/rusticlypredactious 14d ago
The setup() function is only called once when the program first runs and any variables declared there aren't accessible to other functions. You could store your canvas color as a global variable and then store your input data in an array to be redrawn every frame. Check out this example on the processing site: https://processing.org/examples/storinginput.html