// vim: set ts=2 sw=2 et tw=80: const history = { paths: [] } history.pop = (app) => { if (history.paths.length == 0) return; history.paths.pop(); app.redrawAll(); }; history.initializeNewPath = () => { history.paths.push([]); }; history.push = (stroke) => { if (!stroke instanceof Stroke) { throw new Error(JSON.stringify(stroke) + ' is not a Stroke instance'); } history.paths[history.paths.length - 1].push(stroke); } history.clear = () => { history.paths = []; }; class Stroke { constructor(brushName, strokeStyle, x, y) { this.brushName = brushName; this.strokeStyle = strokeStyle; this.offsetX = x; this.offsetY = y; } }