xxxxxxxxxx
44
// A basic example trying to show how push and pop works
//
// By Jon Froehlich
// http://makeabilitylab.io
let grid;
function setup() {
createCanvas(600, 400);
grid = new Grid();
grid.isCheckboardOn = false; // switch to true to get a red/black checkboard
grid.isCenterPtOn = false; // switch to true to draw center pt
//noloop();
}
function draw() {
background(10);
grid.draw();
fill(0, 0, 200); // blue
stroke(255, 0, 255); // purple
strokeWeight(1);
ellipse(150, 100, 100);
// uncomment push/pop to see effect
push(); // save current drawing settings
// push saves the current paint brush and stroke
// which is blue and white
fill(200, 0, 0); // now set fill to red
stroke(255, 255, 255); // stroke to white
strokeWeight(3);
ellipse(300, 100, 100);
pop(); // take out the last paint setting (blue fill, white stroke)
// With push/pop, this last ellipse will be blue with purple outline
ellipse(450, 100, 100);
}