mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-31 16:20:22 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
16a11e1fcc
75
scripts/import_sprite_sheet_command.lua
Normal file
75
scripts/import_sprite_sheet_command.lua
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
-- Copyright (C) 2021 Igara Studio S.A.
|
||||||
|
--
|
||||||
|
-- This file is released under the terms of the MIT license.
|
||||||
|
-- Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
dofile('./test_utils.lua')
|
||||||
|
|
||||||
|
do
|
||||||
|
local s = Sprite(8, 4, ColorMode.INDEXED)
|
||||||
|
assert(#s.cels == 1)
|
||||||
|
|
||||||
|
local i = s.cels[1].image
|
||||||
|
array_to_pixels({ 0, 1, 2, 3, 3, 2, 1, 0,
|
||||||
|
1, 2, 3, 4, 4, 3, 2, 1,
|
||||||
|
1, 2, 3, 4, 4, 3, 2, 1,
|
||||||
|
0, 1, 2, 3, 3, 2, 1, 0 }, i)
|
||||||
|
|
||||||
|
app.command.ImportSpriteSheet{
|
||||||
|
ui=false,
|
||||||
|
type=SpriteSheetType.ROWS,
|
||||||
|
frameBounds=Rectangle(0, 0, 4, 4)
|
||||||
|
}
|
||||||
|
assert(#s.cels == 2)
|
||||||
|
expect_img(s.cels[1].image,
|
||||||
|
{ 0, 1, 2, 3,
|
||||||
|
1, 2, 3, 4,
|
||||||
|
1, 2, 3, 4,
|
||||||
|
0, 1, 2, 3 })
|
||||||
|
expect_img(s.cels[2].image,
|
||||||
|
{ 3, 2, 1, 0,
|
||||||
|
4, 3, 2, 1,
|
||||||
|
4, 3, 2, 1,
|
||||||
|
3, 2, 1, 0 })
|
||||||
|
|
||||||
|
app.undo();
|
||||||
|
app.command.ImportSpriteSheet{
|
||||||
|
ui=false,
|
||||||
|
type=SpriteSheetType.ROWS,
|
||||||
|
frameBounds=Rectangle(0, 0, 2, 3)
|
||||||
|
}
|
||||||
|
assert(#s.cels == 4)
|
||||||
|
expect_img(s.cels[1].image,
|
||||||
|
{ 0, 1,
|
||||||
|
1, 2,
|
||||||
|
1, 2 })
|
||||||
|
expect_img(s.cels[2].image,
|
||||||
|
{ 2, 3,
|
||||||
|
3, 4,
|
||||||
|
3, 4 })
|
||||||
|
expect_img(s.cels[3].image,
|
||||||
|
{ 3, 2,
|
||||||
|
4, 3,
|
||||||
|
4, 3 })
|
||||||
|
expect_img(s.cels[4].image,
|
||||||
|
{ 1, 0,
|
||||||
|
2, 1,
|
||||||
|
2, 1 })
|
||||||
|
|
||||||
|
|
||||||
|
app.undo();
|
||||||
|
app.command.ImportSpriteSheet{
|
||||||
|
ui=false,
|
||||||
|
type=SpriteSheetType.ROWS,
|
||||||
|
frameBounds=Rectangle(1, 1, 2, 2),
|
||||||
|
padding=Size(2, 0)
|
||||||
|
}
|
||||||
|
assert(#s.cels == 2)
|
||||||
|
expect_img(s.cels[1].image,
|
||||||
|
{ 2, 3,
|
||||||
|
2, 3 })
|
||||||
|
expect_img(s.cels[2].image,
|
||||||
|
{ 3, 2,
|
||||||
|
3, 2 })
|
||||||
|
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (C) 2019 Igara Studio S.A.
|
-- Copyright (C) 2019-2021 Igara Studio S.A.
|
||||||
-- Copyright (C) 2018 David Capello
|
-- Copyright (C) 2018 David Capello
|
||||||
--
|
--
|
||||||
-- This file is released under the terms of the MIT license.
|
-- This file is released under the terms of the MIT license.
|
||||||
@ -120,10 +120,22 @@ do
|
|||||||
assert(s.gridBounds == Rectangle{0, 0, 16, 16})
|
assert(s.gridBounds == Rectangle{0, 0, 16, 16})
|
||||||
s.gridBounds = Rectangle{2, 3, 8, 4}
|
s.gridBounds = Rectangle{2, 3, 8, 4}
|
||||||
assert(s.gridBounds == Rectangle{2, 3, 8, 4})
|
assert(s.gridBounds == Rectangle{2, 3, 8, 4})
|
||||||
s:saveAs("_test_sprite_gridbounds.png")
|
s:saveAs("_test_sprite_gridbounds.aseprite")
|
||||||
|
|
||||||
local s2 = Sprite{ fromFile="_test_sprite_gridbounds.png" }
|
local s2 = Sprite{ fromFile="_test_sprite_gridbounds.aseprite" }
|
||||||
assert(s.gridBounds == Rectangle{2, 3, 8, 4})
|
assert(s2.gridBounds == Rectangle{2, 3, 8, 4})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Pixel ratio
|
||||||
|
do
|
||||||
|
local s = Sprite(32, 32)
|
||||||
|
assert(s.pixelRatio == Size{1, 1})
|
||||||
|
s.pixelRatio = Size{3, 2}
|
||||||
|
assert(s.pixelRatio == Size{3, 2})
|
||||||
|
s:saveAs("_test_sprite_pixelratio.aseprite")
|
||||||
|
|
||||||
|
local s2 = Sprite{ fromFile="_test_sprite_pixelratio.aseprite" }
|
||||||
|
assert(s2.pixelRatio == Size{3, 2})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sprite{ fromFile, oneFrame }
|
-- Sprite{ fromFile, oneFrame }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user