Created
February 10, 2019 20:36
-
-
Save bantic/30a269e5d222c4ad2f6eba5081c79455 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 setup() { | |
console.log('hello from p5 setup'); | |
} | |
window.setup = setup; | |
function draw() { | |
window.ellipse(50, 50, 80, 80); | |
} | |
window.draw = draw; | |
function injectP5(callback) { | |
let script = document.createElement('script'); | |
script.setAttribute( | |
'src', | |
'//cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js' | |
); | |
script.onload = () => callback(); | |
script.onerror = e => alert('The script failed to load: ' + e); | |
document.head.appendChild(script); | |
} | |
injectP5(function() { | |
console.log('p5 was injected v2'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment