def _layoutSprintImages(self, images): """ Layout the sprite images in a container that is only bound be height or width depending on which is largest the other dimension will de unlimited in size and the final height and width of the sprite will be determined when the layout is complete. """ (width, height) = self._virtualSpriteSize(images) print str.format("Virtual sprite size {0} x {1}", width, height) layout = Layout(width, height) sorted_images = self._sortSpriteImages(images, width, height) for image in sorted_images: layout.insert(image.width, image.height, image) layout.prune() return layout
def test_layout_locked_width(self): layout = Layout(12, sys.maxint) layout.insert(12, 2, 1) layout.insert(10, 4, 2) layout.insert(10, 2, 3) layout.insert(8, 4, 4) layout.insert(8, 4, 5) layout.insert(6, 2, 6) layout.insert(6, 4, 7) layout.insert(4, 2, 8) layout.insert(4, 2, 9) layout.insert(2, 2, 10) layout.insert(2, 2, 11) layout.insert(2, 2, 12) layout.insert(2, 2, 13) layout.insert(2, 2, 14) layout.prune() (width, height) = layout.bounding() self.assertEqual(12, width) self.assertEqual(22, height) node_count = 0 for node in layout.nodes(): node_count = node_count + 1 self.assertEqual(14, node_count)