Fit elements into box

2019-08-23 02:00发布

I want to achieve the effect shown in the images attached. Given certain items, fit them into a shape (box or something else), with the option to resize the items or not.

I know there has to be some algorithm related, but I don't know where to start looking.

Any keyword, wikipedia article, or pdf will be welcome.

enter image description here enter image description here