// create <img> element let img = document.createElement("img"); // save canvas content as PNG (encoded as string using "data:URL") img.src = canvas.toDataURL(); // append to DOM document.body.appendChild(img); //documentja
JavaScript: The Definitive Guide (15.8 Graphics in a <canvas>)
HTMLCanvasElement ⟩ .toDataURL()
Last updated 2 years ago