Created
January 24, 2020 10:00
-
-
Save johanlunds/0f70d35af5e4bafb9f896e110f2ec80e to your computer and use it in GitHub Desktop.
Paper.js draw image example code
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
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