fix: crash on WebWorkerObserver script execution (#37050)

fix: crash on WebWorkerObserver script execution
This commit is contained in:
Shelley Vohr 2023-01-31 12:29:29 +01:00 committed by GitHub
parent ce35bda805
commit 23739c644b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 16 deletions

View file

@ -0,0 +1,18 @@
class CheckerboardPainter {
paint (ctx, geom, properties) {
const colors = ['red', 'green', 'blue'];
const size = 32;
for (let y = 0; y < (geom.height / size); y++) {
for (let x = 0; x < (geom.width / size); x++) {
const color = colors[(x + y) % colors.length];
ctx.beginPath();
ctx.fillStyle = color;
ctx.rect(x * size, y * size, size, size);
ctx.fill();
}
}
}
}
// eslint-disable-next-line no-undef
registerPaint('checkerboard', CheckerboardPainter);