1.2.8 • Published 2 years ago

spritesheet-js v1.2.8

Weekly downloads
197
License
Creative Commons ...
Repository
github
Last release
2 years ago

spritesheet.js

Spritesheet.js is command-line spritesheet (a.k.a. Texture Atlas) generator written in node.js.

Supported spritesheet formats

  • Starling / Sparrow
  • JSON (i.e. PIXI.js)
  • Easel.js
  • cocos2d (i.e. version 2.x)
  • cocos2d-v3 (i.e. version 3.x)
  • CSS (new!)

Usage

Command Line

$ spritesheet-js assets/*.png

Options:

$ spritesheet-js
Usage: spritesheet-js [options] <files>

Options:
-f, --format  format of spritesheet (starling, sparrow, json, pixi.js, easel.js, cocos2d)                                                          [default: "json"]
-n, --name    name of generated spritesheet                                                                                                        [default: "spritesheet"]
-p, --path    path to export directory                                                                                                             [default: "."]
--fullpath    include path in file name                                                                                                            [default: false]
--prefix      prefix for image paths (css format only)                                                                                             [default: ""]
--trim        removes transparent whitespaces around images                                                                                        [default: false]
--square      texture should be s square                                                                                                           [default: false]
--powerOfTwo  texture width and height should be power of two                                                                                      [default: false]
--validate    check algorithm returned data                                                                                                        [default: false]
--algorithm   packing algorithm: growing-binpacking (default), binpacking (requires passing --width and --height options), vertical or horizontal  [default: "growing-binpacking"]
--width       width for binpacking                                                                                                                 [default: undefined]
--height      height for binpacking                                                                                                                [default: undefined]
--padding     padding between images in spritesheet                                                                                                [default: 0]
--scale       percentage scale                                                                                                                     [default: "100%"]
--fuzz        percentage fuzz factor (usually value of 1% is a good choice)                                                                        [default: ""]

Node.js

var spritesheet = require('spritesheet-js');

spritesheet('assets/*.png', {format: 'json'}, function (err) {
if (err) throw err;

console.log('spritesheet successfully generated');
});

Trimming / Cropping

Spritesheet.js can remove transparent whitespace around images. Thanks to that you can pack more assets into one spritesheet and it makes rendering a little bit faster.

NOTE: Some libraries such as Easel.js dont't support this feature. Trimming / Cropping

Installation

  1. Install ImageMagick
  2. npm install spritesheet-js -g

Test

mocha test

Thanks Przemysław Piekarski for logo design and assets in examples.

1.2.8

2 years ago

1.2.6

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.9.9

9 years ago

0.9.8

9 years ago

0.9.7

9 years ago

0.9.6

9 years ago

0.9.5

9 years ago

0.9.4

9 years ago

0.9.3

9 years ago

0.9.2

9 years ago

0.9.1

9 years ago

0.9.0

9 years ago

0.8.6

9 years ago

0.8.5

9 years ago

0.8.4

10 years ago

0.8.3

10 years ago

0.8.2

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.5

10 years ago

0.6.4

11 years ago

0.6.3

11 years ago

0.6.2

11 years ago

0.6.1

11 years ago

0.6.0

11 years ago

0.5.2

11 years ago

0.5.1

11 years ago

0.5.0

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.8

11 years ago

0.2.7

11 years ago

0.2.6

11 years ago

0.2.5

11 years ago

0.2.4

11 years ago