grunt-free-tex-packer
v0.3.0
Published
Grunt free texture packer
Maintainers
Readme
grunt-free-tex-packer
Free texture packer plugin for grunt
Based on https://github.com/odrick/free-tex-packer
Install
npm install --save-dev grunt-free-tex-packerRequires Node.js 20.9 or newer and grunt 0.4.5 or newer (grunt 1.x is tested).
Basic usage
module.exports = function(grunt) {
grunt.initConfig({
free_tex_packer: {
demo: {
files: [
{expand: true, src: 'src/**/*', basePath: 'src/', filter: 'isFile'}
],
options: {
dest: 'dest'
}
}
}
});
grunt.loadNpmTasks('grunt-free-tex-packer');
grunt.registerTask('default', ['free_tex_packer']);
};Advanced usage
Use packer options object
module.exports = function(grunt) {
grunt.initConfig({
free_tex_packer: {
demo: {
files: [
{expand: true, src: 'src/**/*', basePath: 'src/', filter: 'isFile'}
],
options: {
dest: 'dest',
textureName: "my-texture",
width: 1024,
height: 1024,
fixedSize: false,
padding: 2,
allowRotation: true,
detectIdentical: true,
allowTrim: true,
exporter: "Pixi",
removeFileExtension: true,
prependFolderName: true
}
}
}
});
grunt.loadNpmTasks('grunt-free-tex-packer');
grunt.registerTask('default', ['free_tex_packer']);
};Additional parameters
basePathinfiles- path to be removed from the sprite names in the texture. Without it the names keep the whole path, for examplesrc/sprite.png.destinoptions- destination folder for the result; relative to the folder of theGruntfile. Without it the result is written to that folder itself.
What is packed
Only .png, .jpg, .jpeg and .webp files (in any letter case) are packed; other files and folders matched by the src patterns, such as src/**/*, are ignored.
Errors
The task fails (grunt stops, or goes on with --force) and writes nothing when:
- no image is found
- an image cannot be decoded; the error lists the files
- the packer options are invalid, for example an unknown
exporter
Pack options description: https://github.com/odrick/free-tex-packer-core#available-options
Custom exporters description: https://github.com/odrick/free-tex-packer-core#custom-exporter
Used libs
- Free texture packer core - https://github.com/odrick/free-tex-packer-core
License: MIT
