
https://openprocessing.org/sketch/2797563
let shapes = [];
const shapesNum = 5000;
let maxRadius;
function setup() {
// createCanvas(windowWidth, windowHeight);
createCanvas(800, 800);
maxRadius = min(width, height) * 0.3;
for (let i = 0; i < shapesNum; i++) {
shapes.push(new Shape(i));
}
background("#232323");
}
function draw() {
// ์์์ ์ํด ๋งค ํ๋ ์๋ง๋ค ๋ฐฐ๊ฒฝ ๊ทธ๋ฆผ
background("#2323231A"); // ๋ค์์ ๋ ์๋ฆฌ๋ ์ํ๊ฐ
noStroke();
fill(0);
for (let i = 0; i < shapes.length; i++) {
shapes[i].move();
shapes[i].display();
}
}
class Shape {
constructor(i) {
// ๊ฐ ๋ํ์ ๊ณ ์ ํ ์๊ฐ/์์ ๊ฐ์ผ๋ก ์ฌ์ฉ๋จ
this.i = i * 0.01;
// ๋ฐ์ง๋ฆ ๋ฐฐ์จ
this.radiusMultiplier = 0;
// ๊ฐ๋
this.angle = 0;
// currentRadius
this.currentRadius = i % maxRadius;
}
move() {
// ํ์ฌ ๋ฐ์ง๋ฆ์ ์ ์ ํค์
this.currentRadius += 1;
// ์ต๋ ๋ฐ์ง๋ฆ์ ๋๋ฌํ๋ฉด ๋ค์ 0์ผ๋ก ๋ฆฌ์
if (this.currentRadius > maxRadius) {
this.currentRadius = 0;
}
}
display() {
// ๊ณ ์ ํ i ๊ฐ์ ์ด์ฉํด ๋ณต์กํ ๋ฐ์ง๋ฆ ๋ฐฐ์จ ๊ณ์ฐ
this.radiusMultiplier = (cos(this.i * 3) - cos(this.i * 6) + 9) * 0.45;
// ๊ณ ์ ํ i ๊ฐ์ ์ด์ฉํด ๊ฐ๋ ๊ณ์ฐ
this.angle = this.i / 2 + (sin(this.i * 3) - sin(this.i * 6)) / 3;
// ๊ฐ๋์ ์๊ฐ(frameCount)์ ๋ฐ๋ผ ์์์ด ๋ณํ๊ฒ ํจ
fill(200 * sin(this.angle * 10 + frameCount * 0.1), 120, 100);
// ๊ทน์ขํ๊ณ๋ฅผ ์ด์ฉํด ์์ ์์น ๊ณ์ฐ ๋ฐ ๊ทธ๋ฆฌ๊ธฐ
circle(
this.currentRadius * this.radiusMultiplier * cos(this.angle) + width / 2,
this.currentRadius * this.radiusMultiplier * sin(this.angle) + height / 2,
// ์์ ํฌ๊ธฐ๋ ํ์ฌ ๋ฐ์ง๋ฆ๊ณผ ๊ณ ์ ๊ฐ์ ๋ฐ๋ผ ๋ณํ๊ฒ ํจ
this.currentRadius * 0.2 * sin(this.i * 11)
);
}
}