群れ (2024/11/26)
https://gyazo.com/702fadafbc50bf918e9091941d382332 https://gyazo.com/a84121cfaf75414bb26c660ef632681f https://gyazo.com/ee8a596025a36ad9048677ff36e9959d
https://scrapbox.io/files/67449760b269ba5efdbbaa6b.mp4
code:processing
//#Processing
int n=999, i, s, k;
float a[]=new floatn*2, d, r, x, y; void setup() {
size(800, 800);
for (i=0; i<n*2; i++)ai=400-random(800); }
void draw() {
background(#0080F0);
noStroke();
fill(0);
for (i=0; i<n; i++) {
x=y=0;
for (s=0; s<n; s++)if (i!=s) {
x+=constrain((as-ai)/d/d, -1, 1); y+=constrain((as+n-ai+n)/d/d, -1, 1); }
if (abs(ai+=x)>400)ai*=-1; if (abs(ai+n+=y)>400)ai+n*=-1; circle(ai+400, ai+n+400, 3); }
}