Skip to content

Instantly share code, notes, and snippets.

@fffiloni
Last active July 21, 2022 16:31
Show Gist options
  • Save fffiloni/03deb89f5e5bae9ec0b86dfc3feacefc to your computer and use it in GitHub Desktop.
Save fffiloni/03deb89f5e5bae9ec0b86dfc3feacefc to your computer and use it in GitHub Desktop.
Convert p5js canvas to data then to blob
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