Skip to content

Instantly share code, notes, and snippets.

View BretHudson's full-sized avatar

Bret Hudson BretHudson

View GitHub Profile
@BretHudson
BretHudson / problem.js
Last active November 26, 2023 23:51
Creating a "scoped" render that then undoes all the operations so you don't have to store temporary variables for an eventual reset
// whatever your canvas initialization code is
// just creating a canvas in JS and not putting in the DOM since this is just an example
const canvas = document.createElement('canvas');
const ctx = canvas.getContext("2d");
// get previous values
const prevFillStyle = ctx.fillStyle;
const prevFillStyle = ctx.strokeStyle;
// update the values