Created
January 2, 2021 14:58
-
-
Save Jagathishrex/562c1064de3da1810b3d8a224a90bea8 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
let canvas; | |
let ctx; | |
function animate() { | |
// some animations | |
self.requestAnimationFrame(animate); | |
} | |
self.onmessage = function(ev) { | |
if(ev.data.msg === 'offscreen') { | |
canvas = ev.data.canvas; | |
ctx = canvas.getContext('2d'); | |
animate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment