xxxxxxxxxx
/*
Oryan Inbar Nature of code, ITP, NYU
OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/170022*@*
!do not delete the line above, required for linking your tweak if you upload again
based on Jerome Herr "Stars wave"
*/
float unit1; //the spread of the dots
float theta; //
int num = 25; //tie to amount of movers
int frames=180; //velocity of frames - highr = slower
void setup() {
size(600, 600);
unit1 = width/num; //controls the spread of dots (if not square)
}
void draw() {
// background(255);
//backgrond with transperency
fill(0, 30);
noStroke();
rectMode(CORNER);
rect(0, 0, width, height);
//dots:
fill(255);
//stroke(0, 150);
//a nested forloop to create grid
for (int y=0; y<=num; y++) {
for (int x=0; x<=num; x++) {
float a = x*unit1;
float b = y*unit1;
PVector mouse = new PVector (mouseX, mouseY);
PVector unit = new PVector (a, b);
float distance = unit.dist(mouse); //from x/y to all dots x/y
float offSet = map(distance, 0, sqrt(sq(width/2)+sq(height/2)), 0, TWO_PI); //mouseY isnt here...
float sz = map(sin(theta+offSet), -1, 1, unit1*.2, unit1*.1); //need to check why is out
float angle = atan2(y*unit1-mouseY, x*unit1-mouseX);
pushMatrix();
translate(unit.x, unit.y);
rotate(angle);
float px = map(sin(theta+offSet), -1, 1, 0, 50);
float py = map(cos(theta+offSet), -1, 1, 0, 50);
rectMode(CENTER);
stroke(0);
rect(px, 0, sz*10, sz*20);
strokeWeight(5);
stroke(20, 90, 255, 10);
line(px, 0, py, 0);
strokeWeight(.1);
stroke(255);
line(px, 0, py, 0);
// beginShape();
// vertex(px, 0);
// endShape();
popMatrix();
}
}
theta += TWO_PI/frames;
}