Skip to content

Instantly share code, notes, and snippets.

@pokatomnik
Created November 6, 2018 21:20
Show Gist options
  • Save pokatomnik/0367fd292cf3920a332bca59ea71ee65 to your computer and use it in GitHub Desktop.
Save pokatomnik/0367fd292cf3920a332bca59ea71ee65 to your computer and use it in GitHub Desktop.
Draw in the another window canvas
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