in reply to Rectangle packing...
I hope this code makes sense. If you make width and height "properties" of the photos, it's just a matter of dividing the canvas into vertical and horizontal components, iterating through the photos, and throwing an exception when you've gotten too much on the canvas (or at least, that's how I've thought about it).$canvas{width} = 8.5; $canvas{height} = 11; foreach(@pictures_to_canvas){ if ( ($canvas{width} > $$_{width}) && ($canvas{height} > $$_{width +}) { $canvas{width} -= $$_{width}; $canvas{height} -= $$_{height}; } #Throw exception here if height or width goes below a min value. } ...
|
|---|