Resizing N # of squares to be as big as possible while still fitting into box of X by Y dimensions. (Thumbnails!)
I have N squares. I have a Rectangular box. I want all the squares to fit in the box. I want the squares to be as large as possible. How do I calculate the largest size for the squares such that they all fit in the box? This is for thumbnails in a thumbnail gallery. int function thumbnailSize( iItems, // The number of items to fit. iWidth, // The width of the container. iHeight, // The height of the container. iMin // The smallest an item can be. ) { // if there are no items we don't care how big they are! if (iItems = 0) return 0; // Max size is whichever dimension is smaller, height or width