sequence-paths

generate an array of paths to load an image sequence assets


Keywords
array, images, image sequence, paths, util
License
MIT
Install
npm install sequence-paths@1.0.0

Documentation

sequence-paths

Create an array of sequential filenames between a provided range and with a consistent length of numerals.

NPM

##Usage

sequencePaths( basePath, lastFrame, [extension, numLength, firstFrame] )

  • String basePath the beginning of the file location
  • Number lastFrame the number on the filename of the last frame, inclusive.
  • String [extension] the file-extension, defaults to '.png'
  • Number [numLength] the number of leading-zeros for numbers, defaults to 4
  • Number [firstFrame] the first frame of the sequence, inclusive, defaults to 0

Basic usage:

var sequencePaths = require('sequence-paths');

sequencePaths('/images/intro-', 16, 'jpg');
//=> ['/images/intro-00000.jpg', …, '/images/intro-00016.jpg']

Customize the length of each number in the files string, here all numbers will be 2 characters long:

sequencePaths('images/intro-', 16, 'jpg', 2)
//=> ['/images/intro-00.jpg', …, '/images/intro-16.jpg']

Start the sequence on a frame number other than 0:

sequencePaths('images/intro-', 32, 'jpg', 3, 17)
//=> ['/images/intro-017.jpg', …, '/images/intro-032.jpg']

##License

MIT, see LICENSE.md for details.