function moire(size, palette, parameters) {
const [w, h] = size;
const [a, b, c, d, e] = parameters;
return function(elapsedTime, data) {
const t = elapsedTime / 1000;
const cx1 = Math.sin(t / a) * w / 3 + w / 2;
const cy1 = Math.sin(t / b) * h / 3 + h / 2;
const cx2 = Math.cos(t / c) * w / 3 + w / 2;
const cy2 = Math.cos(t / d) * h / 3 + h / 2;
let i = 0;
for (let y = 0; y < h; y++) {
const dy1 = (y - cy1) ** 2;
const dy2 = (y - cy2) ** 2;
for (let x = 0; x < w; x++) {
const dx1 = (x - cx1) ** 2;
const dx2 = (x - cx2) ** 2;
const hy1 = Math.sqrt(dx1 + dy1);
const hy2 = Math.sqrt(dx2 + dy2);
const col = (hy1 ^ hy2) >> e & 1;
data[i++] = palette[col][0];
data[i++] = palette[col][1];
data[i++] = palette[col][2];
data[i++] = palette[col][3];
}
}
}
}