lib/imageProcessor.js
function(callback) {
      var asyncFunctions = [];

      for (var i = 0; i < numberOfRows; i++) {
        var rowsImagesPaths = imagesPaths.slice(i * numberOfColumns, i * numberOfColumns + numberOfColumns);
        var lineWidth = width;
        var lineHeight = height;
        var linePath = path.join(temporaryDirectoryPath, 'line-' + i);

        linesPaths.push(linePath);
        asyncFunctions.push(createLine(rowsImagesPaths, linePath, lineWidth, lineHeight, true, 100));
      }

      async.parallel(asyncFunctions, function(error, results) {
        if (error) return callback(error);

        results.forEach(function(line) {
          line.forEach(function(image) {
            if (image.image === path.join(temporaryDirectoryPath, 'transparent.png')) return;

            var spritePathChunks = path.parse(image.sprite).name.match(/-([0-9]+)$/);
            var lineIndex = (spritePathChunks && parseInt(spritePathChunks[1])) || 0;

            image.y = image.y + (lineIndex * height);
            image.sprite = destinationPath;
            images.push(image);
          });
        });

        callback();
      });
    }
function(callback) {
      var asyncFunctions = [];

      for (var i = 0; i < numberOfRows; i++) {
        var rowsImagesPaths = imagesPaths.slice(i * numberOfColumns, i * numberOfColumns + numberOfColumns);
        var lineWidth = width;
        var lineHeight = height;
        var linePath = path.join(temporaryDirectoryPath, 'line-' + i);

        linesPaths.push(linePath);
        asyncFunctions.push(createLine(rowsImagesPaths, linePath, lineWidth, lineHeight, true, 100));
      }

      async.parallel(asyncFunctions, function(error, results) {
        if (error) return callback(error);

        results.forEach(function(line) {
          line.forEach(function(image) {
            if (image.image === path.join(temporaryDirectoryPath, 'transparent.png')) return;

            var spritePathChunks = path.parse(image.sprite).name.match(/-([0-9]+)$/);
            var lineIndex = (spritePathChunks && parseInt(spritePathChunks[1])) || 0;

            image.y = image.y + (lineIndex * height);
            image.sprite = destinationPath;
            images.push(image);
          });
        });

        callback();
      });
    }
function ( callback ) { var asyncFunctions = [ ] ; for ( var i = 0 ; i < numberOfRows ; i ++ ) { var rowsImagesPaths = imagesPaths . slice ( i * numberOfColumns , i * numberOfColumns + numberOfColumns ) ; var lineWidth = width ; var lineHeight = height ; var linePath = path . join ( temporaryDirectoryPath , 'line-' + i ) ; linesPaths . push ( linePath ) ; asyncFunctions . push ( createLine ( rowsImagesPaths , linePath , lineWidth , lineHeight , true , 100 ) ) ; } async . parallel ( asyncFunctions , function ( error , results ) { if ( error ) return callback ( error ) ; results . forEach ( function ( line ) { line . forEach ( function ( image ) { if ( image . image === path . join ( temporaryDirectoryPath , 'transparent.png' ) ) return ; var spritePathChunks = path . parse ( image . sprite ) . name . match ( / -([0-9]+)$ / ) ; var lineIndex = ( spritePathChunks && parseInt ( spritePathChunks [ 1 ] ) ) || 0 ; image . y = image . y + ( lineIndex * height ) ; image . sprite = destinationPath ; images . push ( image ) ; } ) ; } ) ; callback ( ) ; } ) ; }
Create sprite horizontal lines
Create sprite horizontal lines