Created
November 6, 2018 21:20
-
-
Save pokatomnik/0367fd292cf3920a332bca59ea71ee65 to your computer and use it in GitHub Desktop.
Draw in the another window canvas
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 getCanvas() { | |
const newWindow = window.open(''); | |
const link = newWindow.document.createElement('link'); | |
link.rel = 'stylesheet'; | |
link.href = 'https://fonts.googleapis.com/css?family=Poor+Story'; | |
link.onload = function () { | |
const newCanvas = newWindow.document.createElement('canvas'); | |
const newContext = newCanvas.getContext('2d'); | |
newWindow.document.body.appendChild(newCanvas); | |
newContext.font = '50px Poor Story'; | |
newContext.fillText('Hello, world', 50, 50); | |
} | |
newWindow.document.body.appendChild(link); | |
} | |
getCanvas(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment