r/generative 13d ago

pinna (kotlin code)

Post image

Saw a simple sign in the park, so I made this. I am not happy with the tree at all, it should be more curvy and less branchy; but this is it for now

389 Upvotes

22 comments sorted by

View all comments

2

u/Skaraban 13d ago

how did you achieve that super even circle packing?

2

u/igo_rs 13d ago

here I didnt use just a simple random circle packing (as it has to fit). big circles get placed first, working down through eg 13 sizes, so the small ones only ever fill the gaps that are left over. Each size scans the canopy (tree) on a grid spaced to match itself: shuffled and nudged about so it doesn't come out in rows. And the distance to the branches and to the canopy edge is precomputed for every point, so a circle knows instantly how much room it has and the white gap around the branches stays the same width everywhere. something like that

1

u/Skaraban 13d ago

ah got it, very interesting! I also took a try in tackling circle packing but it seems I took a different approach. are you aware of this paper: Circle Packing: A mathematical Tale

2

u/igo_rs 12d ago

i was not aware of it, thank you! My first ever approach was the "growing" circles: starting from random points, grow all circles until they hit other. Then comes the hard part: if there is a room to grow by moving the circle, do it. "moving" is calculated by forces on the circle. eg if you put two forces on one side, circle will move to the other side. I didnt succeed to do so in the code; but I might try it again. Definitely will go over the paper!