// Day16 Glitch — 画面が崩れたような、かっこいい表現を取り入れてみましょう。
/** @param {import('p5')} p */
export default function sketch(p, ctx) {
const { width, height, palette } = ctx;
p.setup = () => {
p.createCanvas(width, height);
p.noStroke();
};
p.draw = () => {
p.background(palette[0]);
const band = 24;
for (let y = 0; y < height; y += band) {
const shift = p.random() < 0.15 ? p.random(-80, 80) : 0;
for (let i = 0; i < 3; i++) {
const c = p.color(palette[2 + i]);
c.setAlpha(170);
p.fill(c);
p.rect(width * 0.2 + shift + (i - 1) * 6, y, width * 0.6, band - 2);
}
}
if (p.frameCount % 40 < 3) {
p.fill(palette[1]);
p.rect(0, p.random(height), width, p.random(2, 12));
}
};
}