Last active
October 25, 2021 17:08
-
-
Save evwltrs/1b0246eb963cb09ade2fcee3d9520daf to your computer and use it in GitHub Desktop.
canvas emoji gen
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
let img = document.createElement("img") | |
img.src = "https://emojiapi.dev/api/v1/crown/400.png" | |
var canvas = document.getElementById("canvas") | |
var ctx = canvas.getContext("2d") | |
ctx.fillStyle = "blue" | |
ctx.fillRect(0, 0, canvas.width, canvas.height) | |
img.addEventListener("load", () => { | |
ctx.drawImage( | |
img, | |
canvas.width / 2 - img.width / 2, | |
canvas.height / 2 - img.height / 2 | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment