Problem Description:
For a small graphic program I want to split an arbitrary sized canvas in an arbitrary number of tiles, whereas the tiles should be quadratic and as big as possible. Naturally there will be borders either on top and bottom - or - at the sides, they should be left blank.
**given:**
width
height
tiles_nr
**wanted:**
tile_size
tiles_nr_x
tiles_nr_y
Example:
I have a Canvas of 800x600 px. I want to place 30 tiles in that area. How big will be one tile? And: How are the tiles distributed in rows and columns?
My appoach so far:
tile_nr_x * tile_nr_y = tiles_nr
tile_nr_x * tile_size <= width
tile_nr_y * tile_size <= height
Are these equations enough to determine the variables? How can this system of equations be solved and implemented in program code?