# \[SOLVED\] Drawing circles inside a circle (generative dandelion)

**URL:** https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197
**Category:** Coding Questions
**Created:** [October 4, 2022, 7:19pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197 "2022-10-04T19:19:41Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 4, 2022, 7:19pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/1 "2022-10-04T19:19:41Z")

</div>

THIS QUESTIONS IS SOLVED! 🙂

Hi I am very new to processing and am trying to do roughly the same [as [this post](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933) (mod edit)], but the resources posted below are not helping me find the solution…

I am now drawing the circles in a different way, and they are not random as I would like them to be.  
See here my code:

```auto
//Creative Challenge 1. Version 0.1
// Date: 04/10/2022
// Author: Taissia Visser
// Name: Dandelion
// Inspired by: 
// core circle                                                                                                                             
int coreRadius = 90;
//dots to be drawn inside the core circle
int dotcoreRadius = 15;
int radius = 10;
void setup() {
  size(1000, 1000);
  background(255);
  ellipseMode(CENTER);
}
void draw() {
  pushMatrix();
  translate(width/2, height/2);
  fill(#E3E5C9);
  ellipse(0, 0, coreRadius, coreRadius);
  // first and second row of dotcircles in core
  dotcore(30);
  dotcore2(10);
  popMatrix();
}
void dotcore(int radius) {
  for (int degrees = 0; degrees < 360; degrees +=36) {
    float angle = radians(degrees);
    float dotXpos = (sin(angle)* radius);
    float dotYpos = (cos(angle)* radius);
    ellipse(dotXpos, dotYpos, dotcoreRadius, dotcoreRadius);
    }
  }
void dotcore2(int radius){
  for(int degrees = 0; degrees < 360; degrees += 120) {
    float angle = radians(degrees);
    float dotXpos = (sin(angle)* radius);
    float dotYpos = (cos(angle)* radius);
    ellipse(dotXpos, dotYpos, dotcoreRadius, dotcoreRadius);
  }
  }

```

Is there anyone who could help me? I think I have to use an if statement here, and I would like to make it so that if the x and y coordinates of the smaller circle are within the bigger circle, it draws the ellipse, else not. I would like to fill the whole outer ellipse with smaller circles.

Besides I was wondering if it also possible to know the (x,y) coordinates of the random circles drawn?

Thanks!

Greetings Ties

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [October 4, 2022, 7:51pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/2 "2022-10-04T19:51:22Z")

</div>

Hello @Ties2901

> [@Ties2901](#):
>
> Besides I was wondering if it also possible to know the (x,y) coordinates of the random circles drawn?

You’ll need to store the x, y coordinates in an array or arrayList. Then you can access them to further manipulate or plug into a println().

Also, this project _might_ be good for using PVector, as it’s a built-in class with several methods available.  
There are several tutorials on PVector on youtube at the **Coding Train**. Beginning overview here:

[![](https://img.youtube.com/vi/7nTLzLf7jUg/hqdefault.jpg "1.2: PVector class - The Nature of Code") ](https://www.youtube.com/watch?v=7nTLzLf7jUg)

Though, this clearly can be done not using PVector. I suggest it only as a possible solution to explore.  
However, since you have an object (a circle) that is a recurring element in your code, you will want to create a class for the circle. So either use the built-in PVector class or write your own class.

🤓

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 4, 2022, 7:59pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/3 "2022-10-04T19:59:43Z")

</div>

> [@Ties2901](#):
>
> dotXpos

Say println (dotXpos, dotYpos);

Use random for radius : radius = random (5, 200);

You can also use the for loop for the number of dots and make a random angle/ degrees

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [October 4, 2022, 8:14pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/4 "2022-10-04T20:14:02Z")

</div>

@Chrisir 's solution is much better!!!

No need to get into writing classes for this. 🙃 I had a momentary bout of madness…  
Please disregard my post.  
🤓

---

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 5, 2022, 7:32am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/5 "2022-10-05T07:32:43Z")

</div>

Hey Chrisir, thanks!

I wanted to create a for or if loop for drawing the random circles (dotcore) within the main circle (core).

I thought about defining the area of the core circle, and create and if statement that tests if the area of the dotsmall circle falls withing the area of the core circle, if so then it draws the dotcore, else not.  
However how to format this in processing is still a bit to advanced for me…

And this I then have to combine with an Array of circles? In that case I definitely need to watch some tutorials about arrays haha.

I have searched for examples but could unfortunately not find anything similar, or something that I understood. Maybe someone could give me an example code?

Thanks!

Kind regards 🙂

Taissia

PS here is what I would like to achieve in the end! It is a creative challenge for my master program in Industrial Design 🙂 So I am mainly learning processing because I would like to generate a cool and interesting visual output.

 ![Creative challenge 1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/f/4f1ff5060a2a95657d57df25e711f6fe9f0e1f07.jpeg)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 5, 2022, 8:05am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/6 "2022-10-05T08:05:40Z")

</div>

In my way above, the circles are just drawn randomly within  
the big circle

To avoid overlapping you need to store data and compare

Google packing algorithms

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 5, 2022, 11:07am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/7 "2022-10-05T11:07:28Z")

</div>

Hello @Ties2901,

You may want to consider a 3D approach to the code; the end result will still be 2D on the screen or printed page.

Example:

> [@Place a circle on the surface of a sphere](https://discourse.processing.org/t/place-a-circle-on-the-surface-of-a-sphere/38770/4):
>
> Hello, You should be able to adapt this to p5.js: A translate, a rotate for phi and a rotate for theta and then draw a circle(): slight_smile

There are other ways to do this and I shared mostly for the visual effect.

Each circle in above topic could be a floret\seed head and generated separately; you just make one, add some randomness and transform (translate and rotate) it… then the next one.

You would have to place or pack circles on a sphere as required… this is very achievable.

> [@Ties2901](#):
>
> I wanted to create a for or if loop for drawing the random circles (dotcore) within the main circle (core).

There is definitely order in nature with a touch of randomness:

> **[Taraxacum](https://en.wikipedia.org/wiki/Taraxacum)**
>
> Taraxacum (/təˈræksəkəm/) is a large genus of flowering plants in the family Asteraceae, which consists of species commonly known as dandelions. The scientific and hobby study of the genus is known as taraxacology. The genus is native to Eurasia and North America, but the two most commonplace species worldwide, T. officinale (the common dandelion) and T. erythrospermum (the red-seeded dandelion), were introduced from Europe into North America, where they now propagate as wildflowers. The Like ...

Cool personal challenge!

`:)`

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [October 5, 2022, 11:35am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/8 "2022-10-05T11:35:14Z")

</div>

Hi

Here is some hints colse for your demand  
I think you need to use 3D  
[https://funprogramming.org/77-A-3D-rotating-cloud-of-points.html](https://funprogramming.org/77-A-3D-rotating-cloud-of-points.html)

[https://funprogramming.org/78-An-array-is-like-a-book-full-of-numbers.html](https://funprogramming.org/78-An-array-is-like-a-book-full-of-numbers.html)

[https://funprogramming.org/79-A-spinning-star-becomes-a-plant.html](https://funprogramming.org/79-A-spinning-star-becomes-a-plant.html)

 ![Screenshot_2022-10-05-14-34-16-440](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/e/1e587250e62b67953dad39ee12c44b1ff88499e3.jpeg)

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 5, 2022, 12:11pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/9 "2022-10-05T12:11:35Z")

</div>

sounds like circle packing with the added requirement of a circular arrangement…

---

<div class="post-metadata">

### Author: ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)
#### Post date: [October 5, 2022, 1:47pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/10 "2022-10-05T13:47:42Z")

</div>

Old forum has some insights… and code 😛  
this box below looks like it’s pointing to the home of the forum, but is actually pointing to a page…

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/23637/circle-packing-problem.html)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

> **[help random distribution of non-overlapping circles - Processing Forum](https://forum.processing.org/one/topic/help-random-distribution-of-non-overlapping-circles.html)**
>
> Processing Forum

---

<div class="post-metadata">

### Author: ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)
#### Post date: [October 5, 2022, 4:29pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/11 "2022-10-05T16:29:29Z")

</div>

It seems like you don’t really want a random sampling of points in the circle so much as you want a uniform distribution of points on a sphere. One of the simplest ways to generate N points approximately uniformly spread out on a sphere is to sample points along a Fibonacci spiral wrapping from pole to pole. Many plants follow a Fibonacci spiral for their seed spacing so this is not only easier to use but quite likely more scientifically accurate for your purpose.

[http://extremelearning.com.au/evenly-distributing-points-on-a-sphere/](http://extremelearning.com.au/evenly-distributing-points-on-a-sphere/) gives a nice description of the equations along with some tweaks to improve the sampling near the poles.

Edit: his follow-up post [http://extremelearning.com.au/how-to-evenly-distribute-points-on-a-sphere-more-effectively-than-the-canonical-fibonacci-lattice/](http://extremelearning.com.au/how-to-evenly-distribute-points-on-a-sphere-more-effectively-than-the-canonical-fibonacci-lattice/) might be a little easier to understand.

```auto
float goldenRatio = (1.0+sqrt(5))*0.5;
int N = 200;
float epsilon = 1.33;
float ballrad = sqrt(2.5/N);

void setup() {
  size( 900, 900, P3D );
  noStroke();
}

void ball( float theta, float phi ) {
  theta *= TAU;
  phi = acos( 1. - 2.*phi );
  pushMatrix();
  translate( cos(theta)*sin(phi), sin(theta)*sin(phi), cos(phi) );
  sphere( ballrad );
  popMatrix();
}

void draw() {
  background( 64 );
  camera( 0, 0, 4, 0, 0, 0, 0, 1, 0 );
  frustum( -1, 1, -1, 1, 2.5, 6.5 );
  lights();
  rotateY( 0.01*frameCount );
  fill( 128 );
  sphere(1.);
  fill( 255 );
  ball( 0, 0 );
  ball( 0, 1 );
  for( int i=1; i<N-1; i++ ) {
    float theta = i / goldenRatio;
    float phi = (i+epsilon)/(N-1+2*epsilon);
    ball( theta, phi );
  }
}

```

---

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 5, 2022, 7:40pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/12 "2022-10-05T19:40:36Z")

</div>

So cool how everyone has its own ideas and imput! Thanks!! First time I have asked ‘the public’ how they would tackle a challenge and I am super amazed by all the replies.

Definitely motivates me to try out the suggestions everyone gave 🙂

Greetings,

Taissia

---

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 6, 2022, 3:21pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/13 "2022-10-06T15:21:02Z")

</div>

Hii everyone,

I have started to work with the Circle Packing Algorithm since I am required to deliver a 2D code and pdf, and not a 3D one (although after this assignment I am definitely going to check 3D objects out because the examples I saw looked super cool).

I am currently following this youtube tutorial:

[![](https://img.youtube.com/vi/QHEQuoIKgNE/maxresdefault.jpg "Coding Challenge #50.1: Animated Circle Packing - Part 1") ](https://www.youtube.com/watch?v=QHEQuoIKgNE&t=1233s)

But I have run into a problem (time 12.40 in the video).

Whenever I try to write this code:

> Dotcore newDT = newDot();  
> if(newDT != null){  
> Dotcore.add(newDT);

It gives me an error; namely that my function Dotcore newDot() { is missing a “;”.  
I have tried to find where to place this “;” but I really cannot debug the code. Is there anyone who knows what is happening?

Here the error, its on the first tab:

```auto
> ArrayList<Dotcore>dotcores;
int corewidth = 90;
int coreheight = 90;
int Xcore = 500;
int Ycore = 500;
void setup () {
  size(1000, 1000);
  dotcores = new ArrayList<Dotcore>();
}
void draw () {
  background(255);
  fill(#EDF0D7);
  ellipse(Xcore, Ycore, corewidth, coreheight);
  Dotcore newDT = newDot();
  if(newDT != null){
    Dotcore.add(newDT);
  for (Dotcore DT : dotcores) {
    if (DT.edges()) {
      DT.growing = false;
    }
    DT.show();
    DT.grow();
  }
}Dotcore newDot() {
  pushMatrix();
  translate(width/2, height/2);
  float x = random(Xcore-corewidth/2, Xcore+coreheight/2);
  float y = random (Ycore- coreheight/2, Ycore+coreheight/2 );
  popMatrix();
  boolean valid = true;
  for (Dotcore DT : dotcores) {
    float d = dist(x, y, DT.x, DT.y);
    if (d<DT.r) {
      valid = false;
      break;
    }
  }
  if (valid) {
    return new Dotcore(x, y);
  } else {
    return null;
  }
}

```

this is my second tab;

```auto
> class Dotcore {
  float x;
  float y;
  float r;
  boolean growing = true;
  Dotcore(float x_, float y_) {
    x = x_;
    y = y_;
    r = 2;
  }
  void grow() {
    if (growing) {
      r = r +1;
    }
  }  
  boolean edges() {
    return (x + r > Xcore + corewidth/2 || x - r < Xcore - corewidth/2 || y + r > Ycore + coreheight/2 || y - r < Ycore - coreheight/2);
  }
  void show() {
    stroke(0);
    fill(#D7DBAF);
    ellipse(x, y, r*2, r*2);
  }
}

```

Thanks! Help is always appreciated 🙂

Greetings Taissia

---

<div class="post-metadata">

### Author: ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)
#### Post date: [October 6, 2022, 3:28pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/14 "2022-10-06T15:28:25Z")

</div>

When posting code please format it…  
I think you are missing a bracket to close `draw()` added below…

```auto
ArrayListdotcores;
int corewidth = 90;
int coreheight = 90;
int Xcore = 500;
int Ycore = 500;
void setup () {
	size(1000, 1000);
	dotcores = new ArrayList();
}
void draw () {
	background(255);
	fill(#EDF0D7);
	ellipse(Xcore, Ycore, corewidth, coreheight);
	Dotcore newDT = newDot();
	if(newDT != null){
		Dotcore.add(newDT);
		for (Dotcore DT : dotcores) {
			if (DT.edges()) {
				DT.growing = false;
			}
			DT.show();
			DT.grow();
		}
	}
}// I think you are missing this '}' here !!

Dotcore newDot() {
	pushMatrix();
	translate(width/2, height/2);
	float x = random(Xcore-corewidth/2, Xcore+coreheight/2);
	float y = random (Ycore- coreheight/2, Ycore+coreheight/2 );
	popMatrix();
	boolean valid = true;
	for (Dotcore DT : dotcores) {
		float d = dist(x, y, DT.x, DT.y);
		if (d<DT.r) {
			valid = false;
			break;
		}
	}
	if (valid) {
		return new Dotcore(x, y);
	} else {
		return null;
	}
}

```

---

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 6, 2022, 6:50pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/15 "2022-10-06T18:50:19Z")

</div>

Sorry, did not receive a message yet from the platform on how to format the code, but just read it!

Unfortunately placing an extra bracket (or two) does not solve the error. It gives me the error:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/8/08d82e7f03ebd15e9d6c77d7359604a37c4dff0b.png)

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [October 6, 2022, 6:59pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/16 "2022-10-06T18:59:58Z")

</div>

Hi @Ties2901  
To format your code use preformatted text

 ![Screenshot_2022-10-06-21-58-07-752](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/b/6bcf98af246fb323b199ea5ecb5bcbcf9bddaa71.jpeg)خ

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 7, 2022, 12:06am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/17 "2022-10-07T00:06:14Z")

</div>

Hello @Ties2901,

Processing Forum guidelines:  
[https://discourse.processing.org/t/guidelines-answering-questions/2145/6](https://discourse.processing.org/t/guidelines-answering-questions/2145/6)

Try to cut and past your code and you will see why we ask the community to format code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

Take a look at this example and make the necessary corrections to your code:

> **[ArrayList of objects / Examples](https://processing.org/examples/arraylistclass.html)**
>
> This example demonstrates how to use a Java ArrayList to store a variable number of objects. Items can be added and removed from the ArrayList. Click the mouse to add bouncing balls.

`:)`

---

<div class="post-metadata">

### Author: ![Ties2901](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Ties2901](https://discourse.processing.org/u/Ties2901)
#### Post date: [October 7, 2022, 5:36pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/18 "2022-10-07T17:36:52Z")

</div>

Hii everyone!

I have continued my project and am experiencing some problems with creating a circular boundary in which the circle can be packed.

Until now I only managed to make this area a square, but how do I make this a circle?

```auto
// Creative Challenge 1. Version.9
// NAME: CRAZY GROWING DANDELION
// DATE: 07/10/2022
// AUTHOR: TAISSIA VISSER
// INSPIRED BY:
// REFERENCES:

ArrayList<Dotcore>dotcores;
int corewidth = 150;
int coreheight = 150;
int Xcore = 500;
int Ycore = 500;
int dotcounter = 20;
float seedsangle = 0.0;
int seedscounter = 100;
int counter = 0;
//ArrayList<Seed>seeds;

void setup () {
  background(255);
  size(1000, 1000);
  dotcores = new ArrayList<Dotcore>();
}

void draw () {
  // CORE DANDELION
  noStroke();
  fill(#EDF0D7);
  ellipse(Xcore, Ycore, corewidth, coreheight);

  // DOTS IN THE CORE
  pushStyle();
  newDot();
  for (Dotcore DT : dotcores) {
    if (DT.edges()) {
      DT.growing = false;
    }
    DT.show();
    DT.grow();
  }
  popStyle();

  pushStyle();
  if (counter == 0) {
    fill(3);
    ellipse(500, 500, 400, 400);
  }
  popStyle();

  stem(500, 520);

pushStyle();
  counter = counter +1;
  if (counter < seedscounter) {
    seeds(500, 500, 85);
  }
  popStyle();
}

void seeds(int x, int y, int radius) {
  seedsangle += random (-5, 5);
  x += (cos(seedsangle)*radius);
  y += (sin(seedsangle)*radius);
  translate (x, y);
  rotate(seedsangle);
  fill(#B4A47A);
  stroke(#98885F);
  strokeWeight(1);
  ellipse(0, 0, 20, 5);
}

void newDot() {
  pushMatrix();
  translate(width/2, height/2);
  float x = random(Xcore-corewidth/2, Xcore+coreheight/2);
  float y = random (Ycore- coreheight/2, Ycore+coreheight/2 );
  popMatrix();

  boolean valid = true;
  for (Dotcore DT : dotcores) {
    float d = dist(x, y, DT.x, DT.y);
    if (d<DT.r) {
      valid = false;
      break;
    }
  }
  if (valid) {
    dotcores.add(new Dotcore(x, y));
  }
}

void stem(int x, int y) {
  pushMatrix();
  translate(x, y);
  strokeWeight(20);
  stroke(#C4C94F);
  line(0, 0+60, 0, height);
  popMatrix();
}

```

this is the second tab

```auto
class Dotcore {

  float x;
  float y;
  float r;

  boolean growing = true;

  Dotcore(float x_, float y_) {
    x = x_;
    y = y_;
    r = 1;
  }

  void grow() {
    if (growing) {
      r = r +1;
    }
  }

  boolean edges() {
    //return (x + r > Xcore + corewidth/2 || x - r < Xcore - corewidth/2 || y + r > Ycore + coreheight/2 || y - r < Ycore - coreheight/2 || r > 7 );

    return (x + r > Xcore + (2*PI*(corewidth/2)) || x - r < Xcore - (2*PI*(corewidth/2)) || y + r > Ycore + (2*PI*(corewidth/2)) || y - r < Ycore -(2*PI*(corewidth/2)) || r > 7 );

    //return (x+(2*PI*r)>Xcore+(2*PI*(corewidth/2))|| x-(2*PI*r) < Xcore-(2*PI*(corewidth/2))|| y + (2*PI*r) > Ycore+(2*PI*(corewidth/2)) || y - (2*PI*r) < Ycore-(2*PI*(corewidth/2)) ||r>7 ) ;

    //return ((2*PI*r)>(2*PI*(corewidth/2))|| (2*PI*r) > (2*PI*(corewidth/2)) || r>7 ) ;
  }

  void show() {
    stroke(#9CA25F);
    strokeWeight(1);
    fill(#E3E8B0);
    ellipse(x, y, r*2, r*2);
  }
}

```

I would love to see your suggestions because i really dont know how to solve this!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/8/082a0ab6b8ed0f837897c50915516af887b38472.png)

As you can see, the dots appear in a rectangular shape, and not the shape of an ellipse.

I created a boolean to return a true or false and with that to stop the circles from forming,

```auto
boolean edges() {
    //return (x + r > Xcore + corewidth/2 || x - r < Xcore - corewidth/2 || y + r > Ycore + coreheight/2 || y - r < Ycore - coreheight/2 || r > 7 );

    return (x + r > Xcore + (2*PI*(corewidth/2)) || x - r < Xcore - (2*PI*(corewidth/2)) || y + r > Ycore + (2*PI*(corewidth/2)) || y - r < Ycore -(2*PI*(corewidth/2)) || r > 7 );

    //return (x+(2*PI*r)>Xcore+(2*PI*(corewidth/2))|| x-(2*PI*r) < Xcore-(2*PI*(corewidth/2))|| y + (2*PI*r) > Ycore+(2*PI*(corewidth/2)) || y - (2*PI*r) < Ycore-(2*PI*(corewidth/2)) ||r>7 ) ;

    //return ((2*PI*r)>(2*PI*(corewidth/2))|| (2*PI*r) > (2*PI*(corewidth/2)) || r>7 ) ;
  }

```

All of these different options did not work. ☹

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [October 7, 2022, 5:49pm UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/19 "2022-10-07T17:49:01Z")

</div>

I think you need to implement the dist() function in combination with your radius measurement variables to detect the outer edge of the circle.  
This video may be of use, though disregard the section about noise() as it is not relevant to what you are solving right now.  
[https://funprogramming.org/60-Are-two-circles-touching-or-intersecting.html](https://funprogramming.org/60-Are-two-circles-touching-or-intersecting.html)  
Hopefully, this is helpful.  
🤓

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 8, 2022, 5:35am UTC](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197/20 "2022-10-08T05:35:55Z")

</div>

Hello @Ties2901,

There is a topic here for random distribution within a circle:

> <https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly>

I was able to integrate with your code and achieve this:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/4/6454b13a961684af25f5bdcee9d5831c95ac238d.png)

`:)`

[Next page](https://discourse.processing.org/t/solved-drawing-circles-inside-a-circle-generative-dandelion/39197.md?page=2)
