Merge branch 'master' into beta

This commit is contained in:
David Capello 2020-08-07 13:09:58 -03:00
commit 8adc0b8832
3 changed files with 64 additions and 1 deletions

View File

@ -1,8 +1,11 @@
-- Copyright (C) 2020 Igara Studio S.A.
-- Copyright (C) 2018 David Capello
--
-- 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(32, 32)
for i = 1,3 do s:newFrame() end
@ -41,3 +44,43 @@ do
assert(cb[1] == b.cels[1])
assert(cb[3] == b.cels[2])
end
-- Some extra tests of newCel() and deleteCel()
do
local s = Sprite(4, 4, ColorMode.INDEXED)
local layer = app.activeLayer
app.bgColor = 0
app.command.BackgroundFromLayer()
expect_img(s.cels[1].image, { 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0 })
-- Crash in old versions undoing newCel() in a background layer
s:newCel(layer, 1)
app.undo()
-- Check that newCel clears with bgColor in background layer
local img = Image(ImageSpec{ width=2, height=2,
colorMode=ColorMode.INDEXED })
array_to_pixels({ 0, 1,
2, 3 }, img)
app.bgColor = Color(1) -- bgColor used to clear the background cel
s:newCel(layer, 1, img, Point(1, 1))
expect_img(s.cels[1].image, { 1, 1, 1, 1,
1, 0, 1, 1,
1, 2, 3, 1,
1, 1, 1, 1 })
app.undo()
-- Check deleteCel()
app.bgColor = Color(2)
s:deleteCel(layer, 1)
expect_img(s.cels[1].image, { 2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2 })
app.undo()
end

View File

@ -4,8 +4,10 @@
-- Read LICENSE.txt for more information.
local none = ColorSpace() -- None
local srgb = ColorSpace{ sRGB }
local srgb = ColorSpace{ sRGB=true }
local none2 = ColorSpace{ sRGB=false }
assert(none ~= srgb)
assert(none == none2)
local spr = Sprite(32, 32)
local cs1 = spr.colorSpace

View File

@ -125,3 +125,21 @@ do
local s2 = Sprite{ fromFile="_test_sprite_gridbounds.png" }
assert(s.gridBounds == Rectangle{2, 3, 8, 4})
end
-- Sprite{ fromFile, oneFrame }
do
local s = Sprite(32, 32)
s:newFrame()
s:saveAs("_test1.png")
assert(#s.frames == 2)
s = Sprite{ fromFile="_test1.png" }
print(#s.frames)
assert(#s.frames == 2)
s = Sprite{ fromFile="_test1.png", oneFrame=true }
assert(#s.frames == 1)
s = Sprite{ fromFile="_test1.png", oneFrame=false }
assert(#s.frames == 2)
end