INNER CODE UNIT · JavaScript
cloneCanvas
Booodaness/Scientific-Notes · Booodaness/_Assets/Presentations/phase-space-analysis-harmonic-oscillators.md/plugin/chalkboard/plugin (copy).js:578
function cloneCanvas(oldCanvas) {
//create a new canvas
var newCanvas = document.createElement('canvas');
var context = newCanvas.getContext('2d');
//set dimensions
newCanvas.width = oldCanvas.width;
newCanvas.height = oldCanvas.height;
//apply the old canvas to the new one
context.drawImage(oldCanvas, 0, 0);
//return the new canvas
return newCanvas;
}
function getCanvas( template, container, board ) {
var idx = container.findIndex(element => element.board === board);
if ( idx === -1 ) {
var canvas = cloneCanvas(template);
if ( !container.length ) {