Skip to content

Instantly share code, notes, and snippets.

@johanlunds
Created January 24, 2020 10:00
Show Gist options
  • Save johanlunds/0f70d35af5e4bafb9f896e110f2ec80e to your computer and use it in GitHub Desktop.
Save johanlunds/0f70d35af5e4bafb9f896e110f2ec80e to your computer and use it in GitHub Desktop.
Paper.js draw image example code
async function fetchImage(url) {
const response = await fetch(url);
const blob = await response.blob();
const imageBitmap = await createImageBitmap(blob);
return imageBitmap;
}
const image = await fetchImage("https://i.imgur.com/tW33eLr.png");
const canvas = await paper.get('supporterCanvas');
const ctx = canvas.getContext('2d');
ctx.drawImage(image, x, y, image.width, image.height);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment