mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Merge branch 'beta'
This commit is contained in:
commit
c7e4416f95
10
run-tests.sh
10
run-tests.sh
@ -47,7 +47,7 @@ if [[ "$filter" == "" ]] || [[ "console" =~ $filter ]]; then
|
||||
echo "Testing console..."
|
||||
echo "uname=$(uname)"
|
||||
|
||||
$ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>$t/tmp_err
|
||||
$ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>&1
|
||||
! grep -q "this should be in the output" $t/tmp && fail "print() text not found in output"
|
||||
! grep -q "assertion failed" $t/tmp && fail "assert() text not found in output"
|
||||
grep -q "this should not be in the output" $t/tmp && fail "text that shouldn't be in the output is"
|
||||
@ -55,7 +55,7 @@ if [[ "$filter" == "" ]] || [[ "console" =~ $filter ]]; then
|
||||
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
||||
echo Ignore console tests on Windows
|
||||
else
|
||||
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>$t/tmp_err
|
||||
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>&1
|
||||
cat >$t/tmp_expected <<EOF
|
||||
hello world
|
||||
1 2 3
|
||||
@ -77,10 +77,8 @@ for script in scripts/*.lua ; do
|
||||
first=1
|
||||
fi
|
||||
echo "Running $script"
|
||||
if ! $ASEPRITE -b --script $script >$t/tmp 2>$t/tmp_err ; then
|
||||
echo FAILED
|
||||
echo STDOUT && cat $t/tmp
|
||||
echo STDERR && cat $t/tmp_err
|
||||
if ! $ASEPRITE -b --script $script >$t/tmp 2>&1 ; then
|
||||
echo FAILED && cat $t/tmp
|
||||
result=1
|
||||
fi
|
||||
done
|
||||
|
@ -558,3 +558,49 @@ do
|
||||
expect_img(j, { 7, 2, 1, 4,
|
||||
3, 6, 5, 0 })
|
||||
end
|
||||
|
||||
-- Fill
|
||||
do
|
||||
local s = Sprite(4, 2, ColorMode.INDEXED)
|
||||
local c = s.cels[1]
|
||||
local i = c.image
|
||||
i:clear(1)
|
||||
array_to_pixels({ 1, 1, 1, 1,
|
||||
1, 1, 1, 1 }, i)
|
||||
app.fgColor = Color{ index=0 }
|
||||
s.selection = Selection(Rectangle(1, 1, 2, 1))
|
||||
app.command.Fill()
|
||||
expect_eq(Rectangle(0, 0, 4, 2), c.bounds)
|
||||
expect_img(i, { 1, 1, 1, 1,
|
||||
1, 0, 0, 1 })
|
||||
|
||||
c.position = { x=0, y=1 }
|
||||
app.fgColor = Color{ index=2 }
|
||||
s.selection = Selection(Rectangle(1, 0, 2, 2))
|
||||
app.command.Fill()
|
||||
expect_eq(Rectangle(0, 0, 4, 3), c.bounds)
|
||||
expect_img(i, { 0, 2, 2, 0,
|
||||
1, 2, 2, 1,
|
||||
1, 0, 0, 1 })
|
||||
|
||||
app.fgColor = Color{ index=0 }
|
||||
s.selection = Selection(Rectangle(0, 0, 3, 3))
|
||||
app.command.Fill()
|
||||
expect_eq(Rectangle(3, 1, 1, 2), c.bounds)
|
||||
expect_img(i, { 1,
|
||||
1 })
|
||||
|
||||
app.undo() -- undo Fill
|
||||
expect_eq(Rectangle(0, 0, 4, 3), c.bounds)
|
||||
expect_img(i, { 0, 2, 2, 0,
|
||||
1, 2, 2, 1,
|
||||
1, 0, 0, 1 })
|
||||
|
||||
expect_eq(Rectangle(0, 0, 3, 3), s.selection.bounds)
|
||||
app.undo() -- undo selection change
|
||||
expect_eq(Rectangle(1, 0, 2, 2), s.selection.bounds)
|
||||
app.undo() -- undo Fill
|
||||
expect_eq(Rectangle(0, 1, 4, 2), c.bounds)
|
||||
expect_img(i, { 1, 1, 1, 1,
|
||||
1, 0, 0, 1 })
|
||||
end
|
||||
|
201
scripts/color_quantization.lua
Normal file
201
scripts/color_quantization.lua
Normal file
@ -0,0 +1,201 @@
|
||||
-- Copyright (C) 2019-2022 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")
|
||||
|
||||
local rgba = app.pixelColor.rgba
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- app.command.ColorQuantization
|
||||
|
||||
do
|
||||
-- One sprite with a background layer
|
||||
local s = Sprite(2, 2)
|
||||
app.command.BackgroundFromLayer()
|
||||
|
||||
local i = s.cels[1].image
|
||||
local p = s.palettes[1]
|
||||
assert(#p == 256)
|
||||
assert(s.colorMode == ColorMode.RGB)
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 1)
|
||||
|
||||
array_to_pixels({ rgba(255, 255, 0), rgba(255, 255, 0),
|
||||
rgba(255, 255, 0), rgba(255, 255, 0) }, i)
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 1)
|
||||
assert(p:getColor(0) == Color(255, 255, 0))
|
||||
|
||||
array_to_pixels({ rgba(255, 0, 0), rgba(255, 0, 0),
|
||||
rgba(255, 255, 0), rgba(255, 255, 0) }, i)
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 2)
|
||||
assert(p:getColor(0) == Color(255, 0, 0))
|
||||
assert(p:getColor(1) == Color(255, 255, 0))
|
||||
|
||||
array_to_pixels({ rgba(255, 0, 0), rgba(255, 0, 0),
|
||||
rgba(255, 255, 0), rgba(0, 0, 255) }, i)
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 3)
|
||||
assert(p:getColor(0) == Color(255, 0, 0))
|
||||
assert(p:getColor(1) == Color(255, 255, 0))
|
||||
assert(p:getColor(2) == Color(0, 0, 255))
|
||||
|
||||
-- Convert the background layer to a transparent layer
|
||||
|
||||
app.command.LayerFromBackground()
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3", withAlpha=false }
|
||||
assert(#p == 4) -- One extra color for transparent layer
|
||||
assert(p:getColor(0) == Color(0, 0, 0))
|
||||
assert(p:getColor(1) == Color(255, 0, 0))
|
||||
assert(p:getColor(2) == Color(255, 255, 0))
|
||||
assert(p:getColor(3) == Color(0, 0, 255))
|
||||
|
||||
app.command.ColorQuantization()
|
||||
assert(#p == 4)
|
||||
assert(p:getColor(0) == Color(0, 0, 0, 0))
|
||||
assert(p:getColor(1) == Color(255, 0, 0))
|
||||
assert(p:getColor(2) == Color(255, 255, 0))
|
||||
assert(p:getColor(3) == Color(0, 0, 255))
|
||||
|
||||
array_to_pixels({ rgba(0, 0, 0), rgba(255, 0, 0),
|
||||
rgba(255, 0, 0), rgba(0, 0, 255) }, i)
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3", withAlpha=false }
|
||||
assert(#p == 4)
|
||||
assert(p:getColor(0) == Color(0, 0, 0))
|
||||
assert(p:getColor(1) == Color(0, 0, 0))
|
||||
assert(p:getColor(2) == Color(255, 0, 0))
|
||||
assert(p:getColor(3) == Color(0, 0, 255))
|
||||
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 4)
|
||||
assert(p:getColor(0) == Color(0, 0, 0, 0))
|
||||
assert(p:getColor(1) == Color(0, 0, 0))
|
||||
assert(p:getColor(2) == Color(255, 0, 0))
|
||||
assert(p:getColor(3) == Color(0, 0, 255))
|
||||
end
|
||||
|
||||
do
|
||||
-- One sprite with a transparent layer + a background layer
|
||||
local s = Sprite(2, 2)
|
||||
local p = s.palettes[1]
|
||||
app.command.BackgroundFromLayer()
|
||||
local bg = s.cels[1].image
|
||||
local fg = s:newCel(s:newLayer(), 1).image
|
||||
|
||||
assert(#s.frames == 1)
|
||||
assert(#s.layers == 2)
|
||||
assert(#s.cels == 2)
|
||||
|
||||
array_to_pixels({ rgba(0, 0, 0, 0), rgba(0, 255, 0),
|
||||
rgba(255, 0, 0), rgba(0, 0, 0, 0) }, fg)
|
||||
array_to_pixels({ rgba(0, 0, 0), rgba(0, 0, 0),
|
||||
rgba(0, 0, 0), rgba(0, 0, 255) }, bg)
|
||||
|
||||
app.command.ColorQuantization{ algorithm="rgb5a3" }
|
||||
assert(#p == 5)
|
||||
assert(p:getColor(0) == Color(0, 0, 0, 0))
|
||||
assert(p:getColor(1) == Color(0, 0, 0))
|
||||
assert(p:getColor(2) == Color(0, 255, 0))
|
||||
assert(p:getColor(3) == Color(255, 0, 0))
|
||||
assert(p:getColor(4) == Color(0, 0, 255))
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- app.command.ChangePixelFormat
|
||||
|
||||
do
|
||||
local s = Sprite(2, 2, ColorMode.RGB)
|
||||
local p = Palette(4)
|
||||
p:setColor(0, Color(0, 0, 0))
|
||||
p:setColor(1, Color(101, 90, 200))
|
||||
p:setColor(2, Color(102, 91, 201))
|
||||
p:setColor(3, Color(103, 92, 203))
|
||||
s:setPalette(p)
|
||||
|
||||
app.command.BackgroundFromLayer()
|
||||
|
||||
local bg = s.cels[1].image
|
||||
array_to_pixels({ rgba(0, 0, 0), rgba(101, 90, 200),
|
||||
rgba(102, 91, 201), rgba(103, 92, 203) }, bg)
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="rgb5a3" }
|
||||
-- Using the 5-bit precision of RGB5A3 will match everything with
|
||||
-- the first palette entry.
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 0, 1,
|
||||
1, 1 })
|
||||
app.undo()
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="octree" }
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 0, 1,
|
||||
2, 3 })
|
||||
app.undo()
|
||||
|
||||
p:setColor(0, Color(0, 0, 0, 0))
|
||||
bg = s.cels[1].image
|
||||
array_to_pixels({ rgba(101, 90, 200, 0), rgba(101, 90, 200),
|
||||
rgba(102, 91, 201), rgba(103, 92, 203, 0) }, bg)
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="octree" }
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 0, 1,
|
||||
2, 0 })
|
||||
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- Tests for issue aseprite/aseprite#3207
|
||||
-- Conversion RGB to INDEXED color mode, in transparent layers, always
|
||||
-- picks index 0 as transparent color, even if the mask color is present
|
||||
-- in the palette.
|
||||
|
||||
do
|
||||
local s = Sprite(2, 3, ColorMode.RGB)
|
||||
local p = Palette(4)
|
||||
p:setColor(0, Color(0, 0, 0))
|
||||
p:setColor(1, Color(255, 0, 0))
|
||||
p:setColor(2, Color(0, 0, 0, 0))
|
||||
p:setColor(3, Color(0, 255, 0))
|
||||
s:setPalette(p)
|
||||
|
||||
local bg = s.cels[1].image
|
||||
array_to_pixels({ rgba(0, 0, 0),rgba(255, 0, 0),
|
||||
rgba(255, 0, 0), rgba(0, 0, 0, 0),
|
||||
rgba(0, 0, 0, 0), rgba(0, 0, 0, 0), }, bg)
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="rgb5a3" }
|
||||
-- Using the 5-bit precision of RGB5A3 will match everything with
|
||||
-- the first palette entry.
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 0, 1,
|
||||
1, 2,
|
||||
2, 2 })
|
||||
app.undo()
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="octree" }
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 0, 1,
|
||||
1, 2,
|
||||
2, 2 })
|
||||
app.undo()
|
||||
|
||||
p:setColor(2, Color(0, 0, 255))
|
||||
s:setPalette(p)
|
||||
bg = s.cels[1].image
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="rgb5a3" }
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 2, 1,
|
||||
1, 0,
|
||||
0, 0 })
|
||||
app.undo()
|
||||
|
||||
app.command.ChangePixelFormat{ format="indexed", rgbmap="octree" }
|
||||
bg = s.cels[1].image
|
||||
expect_img(bg, { 2, 1,
|
||||
1, 0,
|
||||
0, 0 })
|
||||
end
|
@ -16,4 +16,7 @@ do
|
||||
assert(l.name == "My Layer")
|
||||
assert(l.opacity == 128)
|
||||
assert(l.blendMode == BlendMode.MULTIPLY)
|
||||
|
||||
l.data = "Data"
|
||||
assert(l.data == "Data")
|
||||
end
|
||||
|
361
scripts/pixel_perfect.lua
Normal file
361
scripts/pixel_perfect.lua
Normal file
@ -0,0 +1,361 @@
|
||||
-- Copyright (C) 2019-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')
|
||||
|
||||
local spr = Sprite(6, 6)
|
||||
local cel = spr.cels[1]
|
||||
|
||||
-- Point size 1px, solid color, no symmetry, no tiled mode
|
||||
do
|
||||
local title = '1px, solid, no symmetry, no tiled'
|
||||
local red = Color{ r=255, g=0, b=0 }
|
||||
local r = red.rgbaPixel
|
||||
local pixel=Brush{ size=1, type=BrushType.CIRCLE }
|
||||
local testData = {
|
||||
{
|
||||
id='1 - ' .. title .. ': right then down',
|
||||
points={ Point(2, 2), Point(3, 2), Point(3, 3) },
|
||||
expected={ r, 0,
|
||||
0, r }
|
||||
},
|
||||
{
|
||||
id='2 - ' .. title .. ': down then right',
|
||||
points={ Point(2, 2), Point(2, 3), Point(3, 3) },
|
||||
expected={ r, 0,
|
||||
0, r }
|
||||
},
|
||||
{
|
||||
id='3 - ' .. title .. ': left then up',
|
||||
points={ Point(2, 2), Point(1, 2), Point(1, 1) },
|
||||
expected={ r, 0,
|
||||
0, r }
|
||||
},
|
||||
{
|
||||
id='4 - ' .. title .. ': up then left',
|
||||
points={ Point(2, 2), Point(2, 1), Point(1, 1) },
|
||||
expected={ r, 0,
|
||||
0, r }
|
||||
}
|
||||
}
|
||||
|
||||
for i,v in ipairs(testData) do
|
||||
app.useTool{
|
||||
tool='pencil',
|
||||
freehandAlgorithm=1,
|
||||
brush=pixel,
|
||||
color=red,
|
||||
points=v.points}
|
||||
expect_img_msg(cel.image, v.expected, '\nTest \'' .. v.id .. '\' failed')
|
||||
cel.image:clear(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Point size 2px, translucent color, no symmetry, no tiled mode
|
||||
do
|
||||
local title = '2px, translucent, no symmetry, no tiled'
|
||||
local red = Color{ r=255, g=0, b=0, a=127 }
|
||||
local r = red.rgbaPixel
|
||||
local square=Brush{ size=2, type=BrushType.SQUARE }
|
||||
local testData = {
|
||||
{
|
||||
id='1 - ' .. title .. ': right then down',
|
||||
points={ Point(2, 2), Point(3, 2), Point(3, 3) },
|
||||
expected={ r, r, 0,
|
||||
r, r, r,
|
||||
0, r, r }
|
||||
},
|
||||
{
|
||||
id='2 - ' .. title .. ': down then right',
|
||||
points={ Point(2, 2), Point(2, 3), Point(3, 3) },
|
||||
expected={ r, r, 0,
|
||||
r, r, r,
|
||||
0, r, r }
|
||||
},
|
||||
{
|
||||
id='3 - ' .. title .. ': left then up',
|
||||
points={ Point(2, 2), Point(1, 2), Point(1, 1) },
|
||||
expected={ r, r, 0,
|
||||
r, r, r,
|
||||
0, r, r }
|
||||
},
|
||||
{
|
||||
id='4 - ' .. title .. ': up then left',
|
||||
points={ Point(2, 2), Point(2, 1), Point(1, 1) },
|
||||
expected={ r, r, 0,
|
||||
r, r, r,
|
||||
0, r, r }
|
||||
}
|
||||
}
|
||||
|
||||
for i,v in ipairs(testData) do
|
||||
app.useTool{
|
||||
tool='pencil',
|
||||
freehandAlgorithm=1,
|
||||
brush=square,
|
||||
color=red,
|
||||
points=v.points}
|
||||
expect_img_msg(cel.image, v.expected, '\nTest \'' .. v.id .. '\' failed')
|
||||
cel.image:clear(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Point size 2px, translucent color, symmetry, no tiled mode
|
||||
do
|
||||
local pref = app.preferences
|
||||
local docPref = pref.document(spr)
|
||||
pref.symmetry_mode.enabled = true
|
||||
docPref.symmetry.mode = 3
|
||||
docPref.symmetry.x_axis = 3
|
||||
docPref.symmetry.y_axis = 3
|
||||
|
||||
local title = '2px, translucent, symmetry on, no tiled'
|
||||
local red = Color{ r=255, g=0, b=0, a=127 }
|
||||
local r = red.rgbaPixel
|
||||
local square=Brush{ size=2, type=BrushType.SQUARE }
|
||||
local testData = {
|
||||
{
|
||||
id='1 - ' .. title .. ': right then down',
|
||||
points={ Point(1, 1), Point(2, 1), Point(2, 2) },
|
||||
expected={ r, r, 0, 0, r, r,
|
||||
r, r, r, r, r, r,
|
||||
0, r, r, r, r, 0,
|
||||
0, r, r, r, r, 0,
|
||||
r, r, r, r, r, r,
|
||||
r, r, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='2 - ' .. title .. ': down then right',
|
||||
points={ Point(1, 1), Point(1, 2), Point(2, 2) },
|
||||
expected={ r, r, 0, 0, r, r,
|
||||
r, r, r, r, r, r,
|
||||
0, r, r, r, r, 0,
|
||||
0, r, r, r, r, 0,
|
||||
r, r, r, r, r, r,
|
||||
r, r, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='3 - ' .. title .. ': left then up',
|
||||
points={ Point(2, 2), Point(1, 2), Point(1, 1) },
|
||||
expected={ r, r, 0, 0, r, r,
|
||||
r, r, r, r, r, r,
|
||||
0, r, r, r, r, 0,
|
||||
0, r, r, r, r, 0,
|
||||
r, r, r, r, r, r,
|
||||
r, r, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='4 - ' .. title .. ': up then left',
|
||||
points={ Point(2, 2), Point(2, 1), Point(1, 1) },
|
||||
expected={ r, r, 0, 0, r, r,
|
||||
r, r, r, r, r, r,
|
||||
0, r, r, r, r, 0,
|
||||
0, r, r, r, r, 0,
|
||||
r, r, r, r, r, r,
|
||||
r, r, 0, 0, r, r }
|
||||
}
|
||||
}
|
||||
|
||||
for i,v in ipairs(testData) do
|
||||
app.useTool{
|
||||
tool='pencil',
|
||||
freehandAlgorithm=1,
|
||||
brush=square,
|
||||
color=red,
|
||||
points=v.points}
|
||||
expect_img_msg(cel.image, v.expected, '\nTest \'' .. v.id .. '\' failed')
|
||||
cel.image:clear(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Point size 2px, translucent color, no symmetry, tiled mode on
|
||||
do
|
||||
local pref = app.preferences
|
||||
local docPref = pref.document(spr)
|
||||
pref.symmetry_mode.enabled = false
|
||||
docPref.tiled.mode = 3
|
||||
|
||||
local title = '2px, translucent, no symmetry, tiled'
|
||||
local red = Color{ r=255, g=0, b=0, a=127 }
|
||||
local r = red.rgbaPixel
|
||||
local square=Brush{ size=2, type=BrushType.SQUARE }
|
||||
local testData = {
|
||||
-- Top left corner
|
||||
{
|
||||
id='1 - ' .. title .. ': on top left corner, right then down',
|
||||
points={ Point(0, 0), Point(1, 0), Point(1, 1) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='2 - ' .. title .. ': on top left corner, down then right',
|
||||
points={ Point(0, 0), Point(0, 1), Point(1, 1) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='3 - ' .. title .. ': on top left corner, left then up',
|
||||
points={ Point(0, 0), Point(-1, 0), Point(-1, -1) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='4 - ' .. title .. ': on top left corner, up then left',
|
||||
points={ Point(0, 0), Point(0, -1), Point(-1, -1) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
-- Top right corner
|
||||
{
|
||||
id='5 - ' .. title .. ': on top right corner, right then down',
|
||||
points={ Point(6, 0), Point(7, 0), Point(7, 1) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='6 - ' .. title .. ': on top right corner, down then right',
|
||||
points={ Point(6, 0), Point(6, 1), Point(7, 1) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='7 - ' .. title .. ': on top right corner, left then up',
|
||||
points={ Point(6, 0), Point(5, 0), Point(5, -1) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='8 - ' .. title .. ': on top right corner, up then left',
|
||||
points={ Point(6, 0), Point(5, 0), Point(5, -1) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
-- Bottom left corner
|
||||
{
|
||||
id='9 - ' .. title .. ': on bottom left corner, right then down',
|
||||
points={ Point(0, 6), Point(1, 6), Point(1, 7) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='10 - ' .. title .. ': on bottom left corner, down then right',
|
||||
points={ Point(0, 6), Point(0, 7), Point(1, 7) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='11 - ' .. title .. ': on bottom left corner, left then up',
|
||||
points={ Point(0, 6), Point(-1, 6), Point(-1, 5) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='12 - ' .. title .. ': on bottom left corner, up then left',
|
||||
points={ Point(0, 6), Point(0, 5), Point(-1, 5) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
-- Botomm right corner
|
||||
{
|
||||
id='13 - ' .. title .. ': on bottom right corner, right then down',
|
||||
points={ Point(6, 6), Point(7, 6), Point(7, 7) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='14 - ' .. title .. ': on bottom right corner, down then right',
|
||||
points={ Point(6, 6), Point(6, 7), Point(7, 7) },
|
||||
expected={ r, r, 0, 0, 0, r,
|
||||
r, r, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
r, 0, 0, 0, 0, r }
|
||||
},
|
||||
{
|
||||
id='15 - ' .. title .. ': on bottom right corner, left then up',
|
||||
points={ Point(6, 6), Point(5, 6), Point(5, 5) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
{
|
||||
id='16 - ' .. title .. ': on bottom right corner, up then left',
|
||||
points={ Point(6, 6), Point(6, 5), Point(5, 5) },
|
||||
expected={ r, 0, 0, 0, 0, r,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, r, r,
|
||||
r, 0, 0, 0, r, r }
|
||||
},
|
||||
}
|
||||
|
||||
for i,v in ipairs(testData) do
|
||||
app.useTool{
|
||||
tool='pencil',
|
||||
freehandAlgorithm=1,
|
||||
brush=square,
|
||||
color=red,
|
||||
points=v.points}
|
||||
expect_img_msg(cel.image, v.expected, '\nTest \'' .. v.id .. '\' failed')
|
||||
cel.image:clear(0)
|
||||
end
|
||||
end
|
@ -21,4 +21,7 @@ do
|
||||
assert(a.pivot == nil)
|
||||
a.pivot = Point(16, 17)
|
||||
assert(a.pivot == Point(16, 17))
|
||||
|
||||
a.data = "Data"
|
||||
assert(a.data == "Data")
|
||||
end
|
||||
|
@ -35,4 +35,7 @@ do
|
||||
assert(a.color == Color(0, 0, 0))
|
||||
a.color = Color(255, 0, 0)
|
||||
assert(a.color == Color(255, 0, 0))
|
||||
|
||||
a.data = "Data"
|
||||
assert(a.data == "Data")
|
||||
end
|
||||
|
@ -32,6 +32,8 @@ function expect_img(image, expectedPixels)
|
||||
local h = image.height
|
||||
if w*h ~= #expectedPixels then
|
||||
print(debug.traceback())
|
||||
print('Expected pixels: #=' .. #expectedPixels)
|
||||
print('Image size: w=' .. w .. ' h=' .. h .. ' #=' .. w*h)
|
||||
dump_img(image)
|
||||
assert(w*h == #expectedPixels)
|
||||
end
|
||||
@ -75,6 +77,14 @@ function expect_img(image, expectedPixels)
|
||||
end
|
||||
end
|
||||
|
||||
function expect_img_msg(image, expectedPixels, msg)
|
||||
local status, err = pcall(expect_img, image, expectedPixels)
|
||||
if not status then
|
||||
print(msg)
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
|
||||
function array_to_pixels(array, image)
|
||||
local w = image.width
|
||||
local h = image.height
|
||||
|
1119
scripts/tilemap.lua
Normal file
1119
scripts/tilemap.lua
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user