diff --git a/cli/sheet.sh b/cli/sheet.sh index f6e2c2be0..27c46b4aa 100644 --- a/cli/sheet.sh +++ b/cli/sheet.sh @@ -1,5 +1,5 @@ #! /bin/bash -# Copyright (C) 2019-2020 Igara Studio S.A. +# Copyright (C) 2019-2022 Igara Studio S.A. # $1 = first sprite sheet json file # $2 = second sprite sheet json file @@ -331,3 +331,72 @@ assert(#sheet2.meta.layers == 8) assert(json.encode(sheet1.meta.layers) == json.encode(sheet2.meta.layers)) EOF $ASEPRITE -b -script "$d/check.lua" || exit 1 + +# https://github.com/aseprite/aseprite/issues/2600 +# -merge-duplicates -split-layers -trim give incorrect 'frame' coordinates on linked cels +d=$t/issue-2600 +$ASEPRITE -b -list-layers -format json-array -trim -merge-duplicates -split-layers -all-layers "sprites/link.aseprite" -data "$d/sheet.json" -sheet "$d/sheet.png" +cat >$d/check.lua < #sheet.meta.layers) + +app.activeSprite = restoredSprite +app.activeLayer = restoredSprite.layers[#restoredSprite.layers] +for i=1,#restoredSprite.layers-1 do + app.command.MergeDownLayer() +end + +local orig = app.open("sprites/link.aseprite") +app.activeSprite = orig +app.activeLayer = orig.layers[#orig.layers] +for i=1,#orig.layers-1 do + app.command.MergeDownLayer() +end + +assert(orig.width == restoredSprite.width) +assert(orig.height == restoredSprite.height) +assert(#orig.frames == #restoredSprite.frames) +for fr=1,#restoredSprite.frames do + for celIndex1=1,#restoredSprite.cels do + if restoredSprite.cels[celIndex1].frameNumber == fr then + for celIndex2=1,#orig.cels do + if orig.cels[celIndex2].frameNumber == fr then + assert(orig.cels[celIndex2].position == restoredSprite.cels[celIndex1].position) + if orig.cels[celIndex2].image ~= nil and restoredSprite.cels[celIndex1].image ~= nil then + assert(orig.cels[celIndex2].image:isEqual(restoredSprite.cels[celIndex1].image)) + end + end + end + end + end +end +EOF +$ASEPRITE -b -script "$d/check.lua" || exit 1 diff --git a/sprites/link.aseprite b/sprites/link.aseprite new file mode 100644 index 000000000..461eba73e Binary files /dev/null and b/sprites/link.aseprite differ