Created
February 17, 2020 13:14
-
-
Save Nekodigi/3721bfc3ea6f1368495c1296fac419f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<Agent> agents = new ArrayList<Agent>(); | |
float zoff = 0; | |
int maxAgent = 4000; | |
void setup(){ | |
//size(500, 500); | |
fullScreen(); | |
colorMode(HSB, 360, 100, 100); | |
background(360); | |
} | |
void keyPressed(){ | |
if(key=='r'){ | |
background(360); | |
agents = new ArrayList<Agent>(); | |
} | |
} | |
void draw(){ | |
noStroke(); | |
for(int i = 0; i < 10; i++){ | |
agents.add(new Agent(zoff)); | |
if(agents.size() > maxAgent){ | |
agents.remove(0); | |
}//sin(zoff)*50+50 | |
fill((zoff)%360+200, 100, 100, sin(zoff*10)*2+2); | |
for(Agent agent : agents){ | |
agent.update(); | |
agent.show(); | |
} | |
zoff += 0.001; | |
} | |
} | |
class Agent{ | |
PVector pos = new PVector(); | |
float nScale = 1000; | |
float zoff; | |
Agent(float zoff){ | |
this.zoff = zoff; | |
pos = new PVector(width/2, height/2); | |
} | |
void update(){ | |
//float angle = noise(pos.x/nScale, pos.y/nScale, zoff)*TWO_PI*4; | |
float angle = (sin(noise(pos.x/nScale, pos.y/nScale, zoff/100)*TWO_PI*2+zoff)+1)/2*TWO_PI*4; | |
pos.add(new PVector(cos(angle), sin(angle))); | |
if(pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height){ | |
pos = new PVector(width/2, height/2); | |
} | |
} | |
void show(){ | |
//pixels[(int)pos.y*width+(int)pos.x-1] = col; | |
rect(pos.x, pos.y, 1, 1);//I want to use alpha | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment