mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 12:39:57 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
2907b176d6
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2018-2021 Igara Studio S.A.
|
||||
Copyright (c) 2018-2022 Igara Studio S.A.
|
||||
Copyright (c) 2018 David Capello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
71
cli/sheet.sh
71
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 <<EOF
|
||||
local json = dofile('third_party/json/json.lua')
|
||||
local sheet = json.decode(io.open('$d/sheet.json'):read('a'))
|
||||
local restoredSprite = Sprite(sheet.frames[1].sourceSize.w, sheet.frames[1].sourceSize.h, ColorMode.RGB)
|
||||
local spriteSheet = Image{ fromFile="$d/sheet.png" }
|
||||
local lay = 1
|
||||
repeat
|
||||
local layerName = sheet.meta.layers[lay].name
|
||||
local layer = restoredSprite.layers[lay]
|
||||
for i=1, #sheet.frames do
|
||||
if string.find(sheet.frames[i].filename, layerName) ~= nil then
|
||||
local sample = sheet.frames[i]
|
||||
local dotAseIndex = string.find(sample.filename, ".ase")
|
||||
local frame = (string.sub(sample.filename, dotAseIndex - 2, dotAseIndex - 1)) + 1
|
||||
for f=#restoredSprite.frames, frame-1 do
|
||||
restoredSprite:newEmptyFrame()
|
||||
end
|
||||
local image = Image(sample.frame.w, sample.frame.h)
|
||||
for y=0,image.height-1 do
|
||||
for x=0,image.width-1 do
|
||||
image:drawPixel(x, y, spriteSheet:getPixel(sample.frame.x + x, sample.frame.y + y))
|
||||
end
|
||||
end
|
||||
restoredSprite:newCel(layer, frame, image, Point(sample.spriteSourceSize.x, sample.spriteSourceSize.y))
|
||||
end
|
||||
end
|
||||
if lay < #sheet.meta.layers then
|
||||
restoredSprite:newLayer()
|
||||
end
|
||||
lay = lay + 1
|
||||
until(lay > #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
|
||||
|
@ -1,3 +1,4 @@
|
||||
-- Copyright (C) 2022 Igara Studio S.A.
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
@ -41,3 +42,4 @@ assert(b.saturation == 0.4)
|
||||
assert(b.value == 0.5)
|
||||
assert(b.alpha == 200)
|
||||
assert(a == b)
|
||||
assert(a ~= 1) -- Comparing with other type fails
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Copyright (C) 2019 Igara Studio S.A.
|
||||
-- Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
@ -204,3 +204,12 @@ do
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Compare layers vs sprites (just return false)
|
||||
|
||||
do
|
||||
local s = Sprite(2, 2)
|
||||
assert(s.layers[1].parent == s)
|
||||
assert(s.layers[1] ~= s) -- Uses Layer_eq() to compare
|
||||
assert(s ~= s.layers[1]) -- Uses Sprite_eq() to compare
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
-- Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
@ -197,3 +197,12 @@ do
|
||||
assert(s.cels[1].image:getPixel(0, 0) == 2)
|
||||
assert(s.cels[1].image:getPixel(1, 0) == 1) -- Get the color of the first layer
|
||||
end
|
||||
|
||||
-- Compare sprite IDs
|
||||
|
||||
do
|
||||
local a = Sprite(1, 1)
|
||||
local b = Sprite(1, 1)
|
||||
assert(a == a)
|
||||
assert(a ~= b) -- Compares IDs, not sprite size
|
||||
end
|
||||
|
BIN
sprites/link.aseprite
Normal file
BIN
sprites/link.aseprite
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user