/* To use: * Pick a size, and set it with the size function * Pick a number of dots, and set dots to that numbe * The output will be called dots.png */ int dots = 30; size(400, 400); int dotlocx[] = new int[dots]; int dotlocy[] = new int[dots]; fill(0); stroke(0); background(255); for(int i = 0; i < dots; i++){ int dotx = int(random(width-20)) + 10; int doty = int(random(height-20)) + 10; int closest = 1000; for(int j = 0; j < i; j++){ int dist = abs(dotlocx[j] - dotx) + abs(dotlocy[j] - doty); if(dist < closest) closest = dist; } if(closest < 20){ i--; continue; } dotlocx[i] = dotx; dotlocy[i] = doty; int r = int(random(5)) + 5; ellipse(dotx, doty, r, r); } save("dots.png"); println("Done");