###

``
Need help reading this?

### generateLayout

index.js

Pack a list of images with width and height into a sprite layout. options object with the following keys:

generateLayout(options: [Object], callback: Function): (DataLayout | ImgLayout)
Parameters
options `([Object])`

Name | Description
--- | ---
options.imgs `[Array<Object>]` | Array of `{ svg: Buffer, id: String }`
options.pixelRatio `[number]` | Ratio of a 72dpi screen pixel to the destination pixel density
options.format `[boolean]` | If true, generate DataLayout ; if false, generate ImgLayout
options.maxIconSize `[boolean]` | optional, overrides the max_size in mapnik
options.removeOversizedIcons `[boolean]` | optional, if set, filters out icons that mapnik says are too big

callback `(Function)` Accepts two arguments, `err` and `layout` Object
Returns
`(DataLayout | ImgLayout)`: layout Generated Layout Object with sprite contents

### generateLayoutUnique

index.js

Same as generateLayout but can be used to dedupe identical SVGs and still preserve the reference.

For example if `A.svg` and `B.svg` are identical, a single icon will be in the sprite image and both A and B will reference the same image

options object with the following keys:

generateLayoutUnique(options: [Object], callback: Function): (DataLayout | ImgLayout)
Parameters
options `([Object])`

Name | Description
--- | ---
options.imgs `[Array<Object>]` | Array of `{ svg: Buffer, id: String }`
options.pixelRatio `[number]` | Ratio of a 72dpi screen pixel to the destination pixel density
options.format `[boolean]` | If true, generate DataLayout ; if false, generate ImgLayout
options.maxIconSize `[boolean]` | optional, overrides the max_size in mapnik
options.removeOversizedIcons `[boolean]` | optional, if set, filters out icons that mapnik says are too big

callback `(Function)` Accepts two arguments, `err` and `layout` Object
Returns
`(DataLayout | ImgLayout)`: layout Generated Layout Object with sprite contents

### generateImage

index.js

Generate a PNG image with positioned icons on a sprite.

generateImage(layout: ImgLayout, callback: Function)
Parameters
layout `(ImgLayout)` An ImgLayout Object used to generate the image
callback `(Function)` Accepts two arguments, `err` and `image` data

### ImgLayout

index.js

Spritezero can generate 2 kinds of layout objects: DataLayout and ImgLayout.

A `ImgLayout` Object contains the array of image items along with dimensions and a buffer of image data that can be used for generating the output image.

ImgLayout
Example

    {
       width: 512,
       height: 512,
       items: [
         {
           "height": 12,
           "width": 12,
           "x": 133,
           "y": 282,
           "buffer": "..."
         }, ... etc ...
       ]
    }

### DataLayout

index.js

Spritezero can generate 2 kinds of layout objects: DataLayout and ImgLayout.

A `DataLayout` Object contains all the metadata about the contents of the sprite. This data can be exported to a JSON sprite manifest file.

The keys of the Object are the icon ids. The values of the Object are the structured data about each icon.

DataLayout
Example

    {
       "aerialway-12": {
         "width": 12,
         "height": 12,
         "pixelRatio": 1,
         "x": 133,
         "y": 282
       }, ... etc ...
    }