Particle particle;
PVector a, dir;
void setup() {
size(600, 600);
background(0);
textSize(10);
smooth();
particle = new Particle(14000);
}
void draw() {
background(0);
strokeWeight(1);
stroke(255);
particle.render();
}
class Particle {
int li;
ArrayList points = new ArrayList();
ArrayList points2 = new ArrayList();
Particle(int d) {
li = d;
for (int i=0; i<d; ++i) {
float x = random(width);
float y = random(height);
points.add(new PVector(x, y));
points2.add(new PVector(x, y));
}
}
void render() {
for (int i=0; i<li; i=i+1) {
PVector po = (PVector)points.get(i);
PVector pp = (PVector)points2.get(i);
a = new PVector(mouseX, mouseY);
PVector dir = PVector.sub(a, po);
dir.normalize();
dir.div(dist(mouseX, mouseY, po.x, po.y)/20);
if (dist(mouseX, mouseY, po.x, po.y)<50) {
if (mousePressed == true) {
po.sub(dir);
}
line(po.x, po.y, pp.x, pp.y);
} else {
line(po.x, po.y, pp.x, pp.y);
}
}
}
}
그리고 void render이후에 시스템 구성을 말로 뭐라 설명해야함?
마우스 좌클릭하면 퍼지고 우클릭하면 다시 모아지는거 만들고싶음
댓글 0