Wave

drawing

A Cosine Function is used in this small program. d = the distance between our mouse position and all points (grid). The radius of ellipse is positive with Cos(d). In the End, “t” is used as time parameter. Dictionary: Find out more mathematical function here: The Beauty of Math.

int t = 0;
float z;

void setup() {
  size(650, 450, P2D);
  smooth();
  noStroke();
}

void draw() {
  background(200);

  for (int i = 10; i < width; i+= 10) {
    for (int j = 10; j < height; j+= 10) { 
      float x = i/10;
      float y = j/10;    
      float d = dist(mouseX/10, mouseY/10, x, y);
      //z = cos(sqrt( (x*x) + (y*y) /*- 0.5*t*/));
      z = cos(d - 0.2*t);
      ellipse(i, j, 10*z, 10*z);
    }
  }
  t++; 
}