int gridWidth = 30;
int gridHeight = 30;
float shapeWidth = 20;
float shapeHeight = 20;
float reactorScaler = .02;
int amplitude = 2;
int xOffset;
int yOffset;
ArrayList<reactorPoint> reactorList = new ArrayList<reactorPoint>();
ArrayList<graphicObject> graphicList = new ArrayList<graphicObject>();
void setup() {
size(800, 800);
xOffset = floor(width/2-(shapeWidth*gridWidth/2));
yOffset = floor(height/2-(shapeHeight*gridHeight/2));
reactorPoint temp = new reactorPoint(400, 400);
reactorList.add(temp);
background(255);
noFill();
for (int i = 0; i<gridWidth; i++ ) {
for (int j = 0; j<gridHeight; j++ ) {
graphicList.add(new graphicObject(i*shapeWidth, j*shapeHeight));
}
}
};
void draw() {
background(255);
pushMatrix();
translate(xOffset, yOffset); //translate array to center of screen
for (int i = 0; i<reactorList.size(); i++ ) {
reactorList.get(i).count();
}
println("reactorList.size() "+reactorList.size());
for (int i = 0; i<graphicList.size(); i++ ) {
graphicList.get(i).draw(reactorList);
}
popMatrix();
};
int mouse_X() {
return (mouseX - xOffset); //correct positions matrix translations
}
int mouse_Y() {
return (mouseY - xOffset); //correct positions matrix translations
}
void mouseClicked() {
reactorPoint temp = new reactorPoint(mouse_X(), mouse_Y());
reactorList.add(temp);
};
class graphicObject {
PVector _loc;
float _scale = 1.0;
graphicObject(float x, float y) {
_loc = new PVector(x, y);
}
void draw(ArrayList<reactorPoint> reList) {
float reactorDistance = 0;
int myStartTime = 0;
float n = 0;
_scale = 1.0;
for (int i = 0; i<reList.size(); i++) {
reactorDistance = dist(reList.get(i)._loc.x, reList.get(i)._loc.y, _loc.x, _loc.y);
myStartTime = int(reList.get(i)._counter-reactorDistance);
n = radians(myStartTime)*1.5;
_scale += sin(n)*amplitude;
}
_scale = _scale/reList.size();
pushMatrix();
translate(_loc.x, _loc.y);
scale(_scale);
strokeWeight(0.2);
ellipse(0, 0, shapeWidth, shapeHeight);
popMatrix();
}
}
class reactorPoint {
PVector _loc;
int _counter;
reactorPoint (int x, int y) {
_counter = 0;
_loc = new PVector(x, y);
}
void count() {
_counter++;
}
}