Created
January 2, 2021 15:29
-
-
Save Jagathishrex/33a1afb8e7d9bd980dea92b68a4da3ca 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
const canvas = document.querySelector('#canvas'); | |
const ctx = canvas.getContext('bitmaprenderer'); // | |
const offscreenCanvas = new OffscreenCanvas(canvas.width, canvas.height); | |
const worker = new Worker('offscreen_worker2.js'); | |
worker.postMessage({msg: 'init', canvas: offscreenCanvas}, [offscreenCanvas]); | |
worker.addEventListener('message', function(ev) { | |
if(ev.data.msg === 'render') { | |
ctx.transferFromImageBitmap(ev.data.bitmap); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment