xxxxxxxxxx
/*
OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/170022*@*
!do not delete the line above, required for linking your tweak if you upload again
*/
float unit; //control sthe spread of the dots
float theta; // controls speed of breathnig
int num = 50; //tie to amount of movers
int frames = 180; //velocity of frames - highr = slower
void setup() {
size(500, 500);
unit = width/num;
}
void draw() {
//add drag to units
fill(0, 110);
rect(0, 0, width, height);
//nsted forloop to make all units
for (int y=0; y<=num; y++) {
for (int x=0; x<=num; x++) {
float distance = dist(mouseX, mouseY, x*unit, y*unit); //dist from center/mouse
float offSet = map(distance, 0, sqrt(sq(width/2)+sq(height/2)), 0, TWO_PI); //pithgorian dist from each cartesian to circular
float sz = map(sin(theta+offSet), -1, 1, unit*.1, unit*.5); //map the size or units to "breath"
float angle = atan2(y*unit-mouseY, x*unit-mouseX); //heading toword center/mouse
//drawing it using sin cos for location to make breathing
pushMatrix();
translate(x*unit, y*unit);
rotate(angle);
float px = map(sin(theta+offSet), -1, 1, 0, 50);
float py = map(cos(theta+offSet), -1, 1, 0, 50);
fill(255);
rect(px, 0, sz, sz*4);
strokeWeight(5);
stroke(20, 90, 255, 10);
line(px, 0, py, 0);
strokeWeight(.1);
stroke(255);
line(px, 0, py, 0);
popMatrix();
}
}
//stroke(255);
theta -= TWO_PI/frames;
}