mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 03:40:57 +00:00
Calculate sprite sheet size correctly when extrude option is checked
This commit is contained in:
parent
dee2dde520
commit
6ba71343dc
@ -118,7 +118,7 @@ namespace {
|
|||||||
|
|
||||||
Fit calculate_sheet_size(Sprite* sprite, int nframes,
|
Fit calculate_sheet_size(Sprite* sprite, int nframes,
|
||||||
int columns, int rows,
|
int columns, int rows,
|
||||||
int borderPadding, int shapePadding, int innerPadding) {
|
int borderPadding, int shapePadding, int innerPadding, bool extrude) {
|
||||||
if (columns == 0) {
|
if (columns == 0) {
|
||||||
rows = MID(1, rows, nframes);
|
rows = MID(1, rows, nframes);
|
||||||
columns = ((nframes/rows) + ((nframes%rows) > 0 ? 1: 0));
|
columns = ((nframes/rows) + ((nframes%rows) > 0 ? 1: 0));
|
||||||
@ -128,9 +128,15 @@ namespace {
|
|||||||
rows = ((nframes/columns) + ((nframes%columns) > 0 ? 1: 0));
|
rows = ((nframes/columns) + ((nframes%columns) > 0 ? 1: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int extrudeColumns = 0;
|
||||||
|
int extrudeRows = 0;
|
||||||
|
if (extrude) {
|
||||||
|
extrudeColumns = columns*2;
|
||||||
|
extrudeRows = rows*2;
|
||||||
|
}
|
||||||
return Fit(
|
return Fit(
|
||||||
2*borderPadding + (sprite->width()+2*innerPadding)*columns + (columns-1)*shapePadding,
|
2*borderPadding + (sprite->width()+2*innerPadding)*columns + (columns-1)*shapePadding + extrudeColumns,
|
||||||
2*borderPadding + (sprite->height()+2*innerPadding)*rows + (rows-1)*shapePadding,
|
2*borderPadding + (sprite->height()+2*innerPadding)*rows + (rows-1)*shapePadding + extrudeRows,
|
||||||
columns, rows, 0);
|
columns, rows, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +594,8 @@ private:
|
|||||||
rowsValue(),
|
rowsValue(),
|
||||||
borderPaddingValue(),
|
borderPaddingValue(),
|
||||||
shapePaddingValue(),
|
shapePaddingValue(),
|
||||||
innerPaddingValue());
|
innerPaddingValue(),
|
||||||
|
extrudeValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
columns()->setTextf("%d", fit.columns);
|
columns()->setTextf("%d", fit.columns);
|
||||||
@ -790,7 +797,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
|||||||
Fit fit = calculate_sheet_size(
|
Fit fit = calculate_sheet_size(
|
||||||
sprite, nframes,
|
sprite, nframes,
|
||||||
columns, rows,
|
columns, rows,
|
||||||
borderPadding, shapePadding, innerPadding);
|
borderPadding, shapePadding, innerPadding, extrude);
|
||||||
if (sheet_w == 0) sheet_w = fit.width;
|
if (sheet_w == 0) sheet_w = fit.width;
|
||||||
if (sheet_h == 0) sheet_h = fit.height;
|
if (sheet_h == 0) sheet_h = fit.height;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user