mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Refactor sprite indicies function
This commit is contained in:
@@ -12,7 +12,7 @@ const DIST_PATH = 'common/dist/sprites/';
|
|||||||
|
|
||||||
// https://github.com/Ensighten/grunt-spritesmith/issues/67#issuecomment-34786248
|
// https://github.com/Ensighten/grunt-spritesmith/issues/67#issuecomment-34786248
|
||||||
const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
|
const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
|
||||||
const SPRITESHEET_SLICE_INDICIES = _calculateSpritesheetsSrcIndicies();
|
const SPRITESHEET_SLICE_INDICIES = _calculateSpritesheetsSrcIndicies(SPRITES_SRC);
|
||||||
|
|
||||||
let spritesTasks = ['sprites:clean'];
|
let spritesTasks = ['sprites:clean'];
|
||||||
|
|
||||||
@@ -43,6 +43,10 @@ each(SPRITESHEET_SLICE_INDICIES, (start, index) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('sprites:largeFiles', () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('sprites:clean', (done) => {
|
gulp.task('sprites:clean', (done) => {
|
||||||
gulp.src(`${DIST_PATH}spritesmith*`)
|
gulp.src(`${DIST_PATH}spritesmith*`)
|
||||||
.pipe(clean());
|
.pipe(clean());
|
||||||
@@ -79,11 +83,11 @@ gulp.task('sprites:compile', spritesTasks, () => {
|
|||||||
gulp.run('sprites:checkCompiledDimensions');
|
gulp.run('sprites:checkCompiledDimensions');
|
||||||
});
|
});
|
||||||
|
|
||||||
function _calculateSpritesheetsSrcIndicies() {
|
function _calculateSpritesheetsSrcIndicies(src) {
|
||||||
let totalPixels = 0;
|
let totalPixels = 0;
|
||||||
let slices = [0];
|
let slices = [0];
|
||||||
|
|
||||||
each(SPRITES_SRC, (img, index) => {
|
each(src, (img, index) => {
|
||||||
let imageSize = _calculateImgDimensions(img, true);
|
let imageSize = _calculateImgDimensions(img, true);
|
||||||
totalPixels += imageSize;
|
totalPixels += imageSize;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user