Tuesday, July 19, 2011

[sjcrteij] Rectangular object layout

You are given a canvas and an ordered sequence of rectangular objects of two types.  One type are "images", with fixed given sizes (images may have different sizes).  The other type are "buttons", for which the layout algorithm may pick a size.

Layout the objects in order, in rows left-to-right then top-to-bottom on the canvas (like text on a page).  The goal is to maximize the minimum dimension of the smallest button.

This first version has rows strictly separated.  All objects in a row are contained within a horizontal band which overlaps with no other band.

Next, generalize by loosening the definition of a row.  Two boxes are adjacent on a row if it is possible to draw a horizontal line between them that passes through no other box.  Also consider to a "tighter" definition where all horizontal lines between them must path through no other box. Also another definition: the next item on a row may be to the right or down.

As an easy first exercise, consider the case where there are no images, only buttons.

As a further generalization, introduce a third type of object, a recursive canvas, which itself contains objects.  The layout algorithm may render the canvas any rectangular size, so long as the internal objects all fit.  Perhaps overlap is permitted into empty space within a recursive canvas.

No comments :