top of page
Writer's pictureKJ Ha

Nature of Code: 4th Assignment


For the fourth assignment, I've decided to develop a polar coordinates example further. My goal was to create multiple polar coordinates to observe different moving patterns among them.



// draw several polar coordinates at once using class
// fifteen random polar coordinates will be created on the canvas
  for (var i = 0; i < 15; i++) {
    var cx = random(width);
    var cy = random(height);
    var cr = random(20, 120);
    var cs = random(1, 8);
    var newCircle = new Circle(cx, cy, cr, cs);
    circles.push(newCircle);
  }
}

The size of the circles and the speed of rotation are subject to be changing constantly.


  display() {
    push();
    translate(this.x, this.y)
    circle(0, 0, this.r * 2);
    strokeWeight(this.w);
    stroke(252, 238, 33);

    this.i = this.r * cos(angle);
    this.j = this.r * sin(angle);
    this.angle = map(mouseX, 0, width, 0, 0.1);
    // console.log(this.angle);
    point(this.i, this.j);

    angle += this.angle;
    this.r += size;
    if (abs(this.r) > this.x) {
      size *= -1;
    }
    pop();
  }
    


Demo




Recent Posts

See All

Nature of Code: Final Proposal

Link to video recording: https://youtu.be/_n7wWtambYc For the final, I would like to continue working on the mid-semester exercise. (link...

ความคิดเห็น


bottom of page