Estoy tratando de generar algunas imágenes usando lienzo, pero todavía veo la imagen anterior en la nueva. Probé algunas formas de borrar imágenes, pero ninguna de estas funciona. Lo que podría faltar aquí:
const canvas = createCanvas(format.width, format.height); const ctx = canvas.getContext("2d", {alpha: false}); for (attributes in attributesList) { await Promise.all(loadedElements).then((renderObjectArray) => { ctx.clearRect(0, 0, format.width, format.height); ctx.beginPath(); // begin //ctx.fillStyle = "white"; ctx.fillRect(0, 0, format.width, format.height); renderObjectArray.forEach((renderObject) => { drawElement(renderObject, attributes); }); }); ctx.closePath(); // close ctx.stroke(); saveImage(); }