Note that this package uses Quantity instead of raw Ints and Floats.
You'll need to install ianmackenzie/elm-units to get started.
Functions for packing boxes together. Scroll down to the Image Packing section if you want to work specifically with images.
Default configuration for packing boxes. Zero spacing and no growing the container width and height to a power of two.
A box we want to pack and its accompanying data. Use this with pack.
powerOfTwoSize sets if the width and height of the container should grow to a power of two size.
Sometimes this is needed when creating texture atlases.spacing sets the minimum separation between boxes.All of the boxes we've packed together and how large the containing region is.
A box, now packed into a larger rectangle.
The width and height of these boxes will be positive even if the corresponding Box had a negative width or height.
Suppose you have a lot of images and you want to load them in as a single image to reduce HTTP requests or simplify texture management in WebGL? With these functions you can generate a texture atlas (also called a sprite sheet) to pack all the images together.
Pack images together to create a single texture atlas image.
Note that this is a slow process.
Even for a small texture atlas (256x256 pixels) it can take a couple seconds and for large images it's probably not a good idea to try.
If you need something fast then it's probably a better idea to just use pack and then draw the texture atlas using an HTML5 canvas or something.
An image we want to pack and its accompanying data. Use this with textureAtlas.
A texture atlas image and accompanying data.
Note that Image may contain functions.
Don't store this data structure in you model.
Instead convert Image into some other format such as Image.toPngUrl.
If you want to save your packed boxes/images and then later load them into an app, these functions (when used with MartinSStewart/elm-codec-bytes) should help.
A codec for TextureAtlas.
A codec for PackedBoxes when dealing with integer values.
A codec for PackedBoxes when dealing with floating point values.
Pack generic boxes together.