# Trouble making ellipses in curving line non-overlapping

**URL:** <https://discourse.processing.org/t/trouble-making-ellipses-in-curving-line-non-overlapping/43709>\
**Category:** Coding Questions\
**Created:** [January 17, 2024, 11:53pm UTC](https://discourse.processing.org/t/trouble-making-ellipses-in-curving-line-non-overlapping/43709 "2024-01-17T23:53:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![druuupppa](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@druuupppa](https://discourse.processing.org/u/druuupppa)\
**Post date:** [January 17, 2024, 11:53pm UTC](https://discourse.processing.org/t/trouble-making-ellipses-in-curving-line-non-overlapping/43709/1 "2024-01-17T23:53:23Z")

</div>

Hello!

I need some help with this code with which I have been making loop-d-loop lines of ellipses. I am having a lot of trouble getting them to draw without overlapping. Any help would be appreciated!

Warmly,  
Druppa

```auto
ArrayList<Circle> circles;
Circle circle;
float noiseScale;
float noiseStrength;

// Let's make sure we don't get stuck in an infinite loop
int protection = 0;
// Does it overlap any previous circles?
boolean overlapping = false;

void setup() {
  size(2000, 1300);

  noiseScale = 6765;
  noiseStrength = 2;
  noiseDetail(3, 0.8);

  circles = new ArrayList<Circle>();

  circle = new Circle();

  // Try to get to 500
  while (circles.size() < 500) {

    overlapping = false;

    circle.update(); // move the circle
    //circle = new Circle();

    for (Circle other : circles) {
      float d = dist(circle.x, circle.y, other.x, other.y);
      if (d < circle.r + other.r) {
        overlapping = true;
        break;
      }
    }

    // If not, keep it!
    if (!overlapping) {
      circles.add(circle);
    }

    // Are we stuck?
    protection++;
    if (protection > 5000) {
      break;
    }
  }

  // Draw all the circles
  for (Circle c : circles) {
    c.display(c.x, c.y, c.r);
  }
}

class Circle {
  float x, y, z, r;
  float speed, n, angle;

  Circle() {
    x = random(144, width-144);
    y = random(144, height-144);
    z = 0.08;
    r = 55;
  }

  void display(float x, float y, float r) {

    fill(255, 0, 175, 100);
    noStroke();
    circle(x, y, r);
  }

  void update() {

    angle = noise(x/noiseScale, y/noiseScale, z)* noiseStrength;
    x += cos (angle) * speed;
    y += sin (angle) * speed;
    //z += 0.008;

    n+=0.08;

    //size = 5+noise(n)*55;
    speed = r;
    speed = speed - noise(n) * speed/144;
    noiseStrength = noiseStrength + noise(n) * sin(0.01)*21;
  }
}

```
