# マウスで線で表された空間をグニャグニャにする

```/**
* force by mouse to lines
*
* @author aa_debdeb
* @date 2016/07/12
*/

int X_STEP = 1;
int Y_STEP = 5;
int X, Y;
float MAX_FORCE = 5.0;
PVector[][] points;

void setup(){
size(500, 500);
stroke(255, 128);
noFill();
X = int(width / X_STEP) + 1;
Y = int(height / Y_STEP) + 1;
points = new PVector[X][Y];
for(int y = 0; y < Y; y += 1){
for(int x = 0; x < X; x += 1){
points[x][y] = new PVector(x * X_STEP, y * Y_STEP);
}
}
}

void keyPressed(){
if(key == 'c'){
points = new PVector[X][Y];
for(int y = 0; y < Y; y += 1){
for(int x = 0; x < X; x += 1){
points[x][y] = new PVector(x * X_STEP, y * Y_STEP);
}
}
}
}

void draw(){
background(0);
for(int y = 0; y < Y; y += 1){
beginShape();
curveVertex(points[0][y].x, points[0][y].y);
for(int x = 0; x < X; x += 1){
curveVertex(points[x][y].x, points[x][y].y);
}
curveVertex(points[X - 1][y].x, points[X - 1][y].y);
endShape();
}
if(mousePressed){
PVector mouse = new PVector(mouseX, mouseY);
for(int y = 0; y < Y; y += 1){
for(int x = 0; x < X; x += 1){
float d = PVector.dist(points[x][y], mouse);