Imaged based circle packing with fixed circle size?

hi

I am trying to do a image based circle packing. and i already found a lot of solutions for this here online.
Now i was wondering if it is possible to set fixed circle sizes (not a range from to) and also set how many of each size?
Here i found circle packing with fixed sizes but not image based:

Is there a way to combine both ideas?

image based circle packing.gh (132.4 KB)

thanks for the help in advance :slight_smile:

Is it important that all your circles end up touching?
Perhaps you could take the output radii from the K2 solver and round them to the radii you want. I’m not sure how you would limit the amount of each radius though.

Then you would probably have gaps and overlaps between the circles but you could use these as an input into another K2 solver that packed the new radii circles.

Just thinking aloud.!

I can imagine a couple of different ways to approach this.
One would be to apply the existing image based circle packing, with continuously varying radii, then replace the radii with values from your set of fixed sizes and run the Collider (or possibly even take the Delaunay mesh and keep the connectivity fixed, and use ClampLength on each edge, with the lower limit as the sum of the radii).

However, this might not look good if the new sizes are very different and the circles have to move a lot, since their sizes will not be updating according to where they are in the image. A more involved but perhaps better way to do this would be to script a new goal, modifying the image based circle packing one so that it gets the continuous radii, sorts them then replaces them with values from the fixed set.

This approach seems similar to this so check it out. Might be helpful.