How to create nested polygon

Oh! :sweat_smile:

Here’s an example:


float ax, ay, bx, by;

void setup() {
  size(400, 400);
  ax = 200;
  ay = 200;
  fill(0);
  stroke(255);
}

void draw() {
  background(0);
  bx = mouseX;
  by = mouseY;
  line(ax, ay, bx, by);
  ellipse(ax, ay, 5, 5);
  ellipse(bx, by, 5, 5);
  float cx = (ax + bx) / 2.0;
  float cy = (ay + by) / 2.0;
  ellipse(cx, cy, 5, 5);
}

void mousePressed() {
  ax = mouseX;
  ay = mouseY;
}
2 Likes