I have been over-thinking this complex and I am sure there is an easy answer or another avenue I can approach to find the solution.
What I am trying to accomplish is a random grid of images. I have an array of images that I want to line up in a flush grid. What I mean by this is that I want the grid to not have any gaps in it. Here are some example images:
Key specs:
- Container/cell must be in a ratio that the image can fit without skewing
- The grid must be flush. It cannot have any gaps including the last row.
The problem I am having is I cannot come up or put into words a formula that can create the table maxtrix I am trying to accomplish. Masonary is 99.9% what I am looking for except the grid does not take into account the image size nor does it end flush. So that 1% is why I am not considering using it.
I am not looking for javascript specific as this relates to math so I plan on creating the layout in PHP then powering functionality in javascript.
Any help or pointers will be appreciated.