Last active
July 21, 2022 16:31
-
-
Save fffiloni/03deb89f5e5bae9ec0b86dfc3feacefc to your computer and use it in GitHub Desktop.
Convert p5js canvas to data then to blob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function graphicsToBlob(){ | |
//for canvas | |
let image64 = canvas.elt.toDataURL('image/png'); | |
//for graphics | |
sourceGraphics.loadPixels(); | |
let image64 = sourceGraphics.canvas.toDataURL('image/png'); | |
fetch(img_data) | |
.then(res => res.blob()) | |
.then(function(newBlob){ | |
console.log(newBlob); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment