2019-08-28 20:19:11 +08:00
|
|
|
-- Copyright (C) 2019 Igara Studio S.A.
|
2018-09-12 05:46:35 +08:00
|
|
|
--
|
|
|
|
-- This file is released under the terms of the MIT license.
|
|
|
|
-- Read LICENSE.txt for more information.
|
|
|
|
|
|
|
|
do
|
2019-08-28 20:19:11 +08:00
|
|
|
local s = Sprite(32, 64)
|
|
|
|
local l = s.layers[1]
|
|
|
|
assert(l.parent == s)
|
2018-09-12 05:46:35 +08:00
|
|
|
assert(l.opacity == 255)
|
|
|
|
assert(l.blendMode == BlendMode.NORMAL)
|
|
|
|
|
|
|
|
l.name = "My Layer"
|
|
|
|
l.opacity = 128
|
|
|
|
l.blendMode = BlendMode.MULTIPLY
|
|
|
|
assert(l.name == "My Layer")
|
|
|
|
assert(l.opacity == 128)
|
|
|
|
assert(l.blendMode == BlendMode.MULTIPLY)
|
2020-10-13 22:52:35 +08:00
|
|
|
|
|
|
|
l.data = "Data"
|
|
|
|
assert(l.data == "Data")
|
2018-09-12 05:46:35 +08:00
|
|
|
end
|
2025-03-12 04:17:22 +08:00
|
|
|
|
2025-04-22 21:51:21 +08:00
|
|
|
-- Test layer uuid with useLayerUuids enabled
|
2025-03-12 04:17:22 +08:00
|
|
|
do
|
|
|
|
local s = Sprite(32, 32)
|
|
|
|
local l = s.layers[1]
|
2025-04-22 21:51:21 +08:00
|
|
|
assert(s.useLayerUuids == false)
|
2025-03-12 04:17:22 +08:00
|
|
|
|
|
|
|
local uuid = l.uuid
|
|
|
|
assert(uuid ~= nil)
|
|
|
|
|
2025-04-22 21:51:21 +08:00
|
|
|
s.useLayerUuids = true
|
2025-03-12 04:17:22 +08:00
|
|
|
|
2025-04-22 21:51:21 +08:00
|
|
|
assert(s.useLayerUuids == true)
|
2025-03-12 04:17:22 +08:00
|
|
|
s.filename = "_test_layer_uuid.aseprite"
|
|
|
|
app.command.SaveFile()
|
|
|
|
app.command.CloseFile()
|
|
|
|
|
|
|
|
app.command.OpenFile { filename = "_test_layer_uuid.aseprite" }
|
2025-04-22 21:51:21 +08:00
|
|
|
assert(app.sprite.useLayerUuids == true)
|
2025-03-12 04:17:22 +08:00
|
|
|
assert(app.sprite.layers[1].uuid == uuid)
|
|
|
|
end
|
|
|
|
|
2025-04-22 21:51:21 +08:00
|
|
|
-- Test layer uuid with useLayerUuids disabled
|
2025-03-12 04:17:22 +08:00
|
|
|
do
|
|
|
|
local s = Sprite(32, 32)
|
|
|
|
local l = s.layers[1]
|
2025-04-22 21:51:21 +08:00
|
|
|
assert(s.useLayerUuids == false)
|
2025-03-12 04:17:22 +08:00
|
|
|
|
|
|
|
local uuid = l.uuid
|
|
|
|
assert(uuid ~= nil)
|
|
|
|
|
|
|
|
s.filename = "_test_layer_uuid_2.aseprite"
|
|
|
|
app.command.SaveFile()
|
|
|
|
app.command.CloseFile()
|
|
|
|
|
|
|
|
app.command.OpenFile { filename = "_test_layer_uuid_2.aseprite" }
|
2025-04-22 21:51:21 +08:00
|
|
|
assert(app.sprite.useLayerUuids == false)
|
|
|
|
-- UUIDs are not equal because it was not saved due to useLayerUuids being
|
2025-03-12 04:17:22 +08:00
|
|
|
-- disabled at the time of saving the file.
|
|
|
|
assert(app.sprite.layers[1].uuid ~= uuid)
|
|
|
|
end
|