Interpret the Extrude option just like one extra inner padding pixel in calculate_sheet_size() function

This commit is contained in:
David Capello 2019-01-25 15:59:44 -03:00
parent 86464bc63c
commit 67e0da478d

View File

@ -120,8 +120,7 @@ namespace {
int columns, int rows,
int borderPadding,
int shapePadding,
int innerPadding,
bool extrude) {
int innerPadding) {
if (columns == 0) {
rows = MID(1, rows, nframes);
columns = ((nframes/rows) + ((nframes%rows) > 0 ? 1: 0));
@ -131,10 +130,9 @@ namespace {
rows = ((nframes/columns) + ((nframes%columns) > 0 ? 1: 0));
}
int extraPerSample = 2*innerPadding + (extrude ? 2: 0);
return Fit(
2*borderPadding + (sprite->width()+extraPerSample)*columns + (columns-1)*shapePadding,
2*borderPadding + (sprite->height()+extraPerSample)*rows + (rows-1)*shapePadding,
2*borderPadding + (sprite->width()+2*innerPadding)*columns + (columns-1)*shapePadding,
2*borderPadding + (sprite->height()+2*innerPadding)*rows + (rows-1)*shapePadding,
columns, rows, 0);
}
@ -602,8 +600,7 @@ private:
rowsValue(),
borderPaddingValue(),
shapePaddingValue(),
innerPaddingValue(),
extrudeValue());
innerPaddingValue() + extrudePadding());
}
columns()->setTextf("%d", fit.columns);
@ -807,7 +804,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
Fit fit = calculate_sheet_size(
sprite, nframes,
columns, rows,
borderPadding, shapePadding, innerPadding, extrude);
borderPadding, shapePadding, innerPadding + extrudePadding);
if (sheet_w == 0) sheet_w = fit.width;
if (sheet_h == 0) sheet_h = fit.height;