float w;
int R = 45; // R = distance where circles will try to get to
float focusDegree = 45;

void setup() {
  size(600,600);
  stroke(0);
  strokeWeight(1);
  smooth();
  w = 0.1;
  noStroke();
  noLoop();
}

void draw() {
  background(255);
  w = map(mouseX, 50, width-50, 5, 0.001);
  w = min(10, w);
  w = max(0.0001, w);

  for ( int i = 0; i < 45; i++ ) { // draw 180 points on circle
    fill(0,0,map(i, 0, 45, 0, 255));
    float oldDegree = 2*i;

    float s = R/(log(w*R+1));
    float deltaDegree = s*log(1+w*abs(focusDegree - oldDegree));
    
    if ( oldDegree < focusDegree ) {
      deltaDegree = -deltaDegree;
    }
    
    float newDegree = focusDegree + deltaDegree;

    float x = 200*cos(radians(newDegree));
    float y = 200*sin(radians(newDegree));
    ellipse(300+x,300+y,5,5);
  }
  
  // Draw the rest of the circle
  fill(0);
  for ( int i = 45; i < 180; i++ ) {
    float degree = 2*i;
    float x = 200*cos(radians(degree));
    float y = 200*sin(radians(degree));
    ellipse(300+x, 300+y, 5, 5);
  }
}

void mouseMoved() {
  redraw();
}