I using canvas graphics to draw objects and need to undo the last drawn object, but could not find any option to delete last object from graphics, please suggest how to delete last object (i.e. creating undo function)
below is the code to in setup() -
canvas=createCanvas(1000,1000);
canvsGraphics = createGraphics(1000,1000);
Below is the object created in mouseDragged() function -
noStroke();
fill(R,G,B);
rectMode(CENTER);
rect(mouseX,mouseY,20,20);
//CREATES BUFFER
canvsGraphics.noStroke();
canvsGraphics.fill(R,G,B);
canvsGraphics.rectMode(CENTER);
canvsGraphics.rect(mouseX,mouseY,20,20);