# パーティクルの視点

```/**
* view from a particle
*
* @author aa_debdeb
* @date 2016/05/16
*/

Particle cP;
ArrayList<Particle> particles;

void setup(){
size(500, 500, P3D);
cP = new Particle();
particles = new ArrayList<Particle>();
for(int i = 0; i < 100; i++){
}
noStroke();
rectMode(CENTER);
}

void draw(){
background(250, 235, 215);
lights();
camera(cP.pos.x, cP.pos.y, 0, cP.pos.x + cP.vel.x, cP.pos.y + cP.vel.y, 0, 0, 0, -1);
fill(240, 250, 100);
pushMatrix();
translate(width / 2, 0, 0);
rotateX(PI / 2);
rect(0, 0, width, 60);
popMatrix();
pushMatrix();
translate(width / 2, height, 0);
rotateX(PI / 2);
rect(0, 0, width, 60);
popMatrix();
pushMatrix();
translate(0, height / 2, 0);
rotateY(PI / 2);
rect(0, 0, 60, height);
popMatrix();
pushMatrix();
translate(width, height / 2, 0);
rotateY(PI / 2);
rect(0, 0, 60, height);
popMatrix();

fill(250, 110, 100);
cP.update();
for(Particle particle: particles){
particle.display();
particle.update();
}
}

class Particle{
PVector pos, vel;
Particle(){
pos = new PVector(random(width), random(height));
float velAng = random(TWO_PI);
vel = new PVector(3 * cos(velAng), 3 * sin(velAng));
}

void update(){
vel.x *= -1;
}
vel.x *= -1;
}
vel.y *= -1;
}
vel.y *= -1;
}
}

void display(){
pushMatrix();
translate(pos.x, pos.y, 0);
popMatrix();
}
}
```