• KJ 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);

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

  display() {
    translate(this.x, this.y)
    circle(0, 0, this.r * 2);
    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;


Recent Posts

See All

Nature of Code: 6th Assignment

Link to code: https://editor.p5js.org/kh1785/sketches/tT1Cj0ZRp9 For this week's assignment, I've created a sketch inspired by one of the video examples, the Game of Life. A lot was taken directly fro

Nature of Code: 5th Assignment

Code: https://editor.p5js.org/kh1785/sketches/_YHzwobV8 For this week's assignment, I've created a simple game using autonomous agents. The rules of the game are simple. At first, five lives are given

Mid-Semester Exercise

Link to code: https://editor.p5js.org/kh1785/sketches/6ADFot4NQ Live sketch: For the mid-semester project, I’ve decided to further develop the week 3 assignment, a p5 sketch simulating a helium-filled

© 2020 Kyungjoo Ha. All Rights Reserved