Tarsier-Marianz_Processing3/sketches/arc_orbiter/arc_orbiter.pde
/* ***************************************************
 * Copyright (c) 2018 Tarsier-Marianz
 * Author: Marianz
 * Created: 2018-04-02
 * Sketch #9 arc_orbiter.pde
 *****************************************************/


int count = 16;

Orbiter[] orbiters;

void setup() {
  size(640, 480);
  strokeWeight(2);
  noFill();
  strokeCap(SQUARE);
  stroke(255);

  initOrbiters();
}

void initOrbiters() {  
  orbiters = new Orbiter[count];
  float minDimen = min(width, height);            //get minimum dimension
  //This is only to make the orbiters' radii evenly divided across the screen
  for (int i = 1; i<=orbiters.length; i++) {
    float startAngle = random(360);
    float sweep = random(30, 180);
    float rotationSpeed = random(90, 540);
    float radius = minDimen * ((float)i/orbiters.length);
    Orbiter o = new Orbiter(width/2, height/2, startAngle, sweep, rotationSpeed, radius);
    //o.radius = minDimen * ((float)i/orbiters.length);
    o.thickness = random(1, 5);
    orbiters[i - 1] = o;
  }
}

void draw() {
  fill(0, 40);
  noStroke();
  rect(-1, -1, width + 1, height + 1);
  noFill();

  for (Orbiter o : orbiters) {    
    o.update();
  }
  colorMode(HSB);
  point(width/2, height/2);
}

class Orbiter {

  float centerX, centerY;

  float sweep = 45;
  float angle;
  float rotationSpeed;
  float radius;
  float thickness = 5;

  public Orbiter(float centerX, float centerY, float startAngle, float sweep, float rotationSpeed, float radius) {
    this.centerX = centerX;
    this.centerY = centerY;
    this.angle = startAngle;
    this.rotationSpeed = rotationSpeed;
    this.radius = radius;
    this.sweep = sweep;
  }

  public void update() {
    angle += rotationSpeed / 60f;
    draw();
  }

  public void draw() {
    colorMode(HSB, 360, 100, 100);
    strokeWeight(thickness);
    float lightness = map(radius, 0, min(width, height), 20, 100);
    stroke(200, 100, lightness);
    arc(centerX, centerY, radius, radius, radians(angle), radians(angle + sweep));
  }
}