// Day15 Rotation — 何かを回転させてみましょう。
/** @param {import('p5')} p */
export default function sketch(p, ctx) {
const { width, height, palette } = ctx;
p.setup = () => {
p.createCanvas(width, height);
p.rectMode(p.CENTER);
p.noFill();
};
p.draw = () => {
p.background(palette[1]);
p.translate(width / 2, height / 2);
for (let i = 0; i < 28; i++) {
p.push();
p.rotate(p.frameCount * 0.004 * (i + 1) * 0.3);
p.stroke(palette[i % 2 === 0 ? 0 : 2]);
p.strokeWeight(1.5);
const s = 40 + i * 16;
p.rect(0, 0, s, s);
p.pop();
}
};
}