# Generating randomly placed circles. without them overlapping

**URL:** https://forum.kirupa.com/t/generating-randomly-placed-circles-without-them-overlapping/297559
**Category:** Uncategorized
**Created:** [October 5, 2009, 1:23pm UTC](https://forum.kirupa.com/t/generating-randomly-placed-circles-without-them-overlapping/297559 "2009-10-05T13:23:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)
#### Post date: [October 5, 2009, 1:23pm UTC](https://forum.kirupa.com/t/generating-randomly-placed-circles-without-them-overlapping/297559/1 "2009-10-05T13:23:41Z")

</div>

for(var a=0; a\<counter; a++){

```
	for(var b=0; b&lt;100; b++){ 

	    var scanXpositions = (storedXPositions[a] - 50) + b;   
	    var scanYpositions = (storedYPositions[a] - 50) + b;

		if((xValue == scanXpositions) || (yValue == scanYpositions)){
	
		  xValue = randomness(650);
		 
   	          yValue = randomness(450);

			 trace("corrected");
			  a = 0;
		}
	
	}
 trace(a);
}

```

THis is what I have but it times out. I think it’s because it has to scan every x/y value a circle would take up…

There has to be a more efficient way of doing this? Like a built in function that detects overlap?
