2023-05-25 01:09:17 +00:00
|
|
|
/* global registerPaint */
|
|
|
|
|
2023-01-31 11:29:29 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
registerPaint('checkerboard', CheckerboardPainter);
|