/***********MISCELLANEOUS UTILITY FUNCTIONS**************/ /** Merges topLayer onto belowLayer * * @param {*} belowLayer The layer on the bottom of the layer stack * @param {*} topLayer The layer on the top of the layer stack */ function mergeLayers(belowLayer, topLayer) { // Copying the above content on the layerBelow let belowImageData = belowLayer.getImageData(0, 0, canvas.width, canvas.height); let toMergeImageData = topLayer.getImageData(0, 0, canvas.width, canvas.height); for (let i=0; i