mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Test bugs using image brush + tiled mode
This commit is contained in:
parent
0b0fbecc26
commit
22c5c2d547
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (C) 2019 Igara Studio S.A.
|
-- Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
--
|
--
|
||||||
-- This file is released under the terms of the MIT license.
|
-- This file is released under the terms of the MIT license.
|
||||||
-- Read LICENSE.txt for more information.
|
-- Read LICENSE.txt for more information.
|
||||||
@ -13,11 +13,26 @@ function expect_eq(a, b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function dump_img(image)
|
||||||
|
local w = image.width
|
||||||
|
local h = image.height
|
||||||
|
print('Image(' .. tostring(w) .. 'x' .. tostring(h) .. ') = {')
|
||||||
|
for v=0,h-1 do
|
||||||
|
local lineStr = ' '
|
||||||
|
for u=0,w-1 do
|
||||||
|
lineStr = lineStr .. image:getPixel(u, v) .. ','
|
||||||
|
end
|
||||||
|
print(lineStr)
|
||||||
|
end
|
||||||
|
print('}')
|
||||||
|
end
|
||||||
|
|
||||||
function expect_img(image, expectedPixels)
|
function expect_img(image, expectedPixels)
|
||||||
local w = image.width
|
local w = image.width
|
||||||
local h = image.height
|
local h = image.height
|
||||||
if w*h ~= #expectedPixels then
|
if w*h ~= #expectedPixels then
|
||||||
print(debug.traceback())
|
print(debug.traceback())
|
||||||
|
dump_img(image)
|
||||||
assert(w*h == #expectedPixels)
|
assert(w*h == #expectedPixels)
|
||||||
end
|
end
|
||||||
for y=0,h-1 do
|
for y=0,h-1 do
|
||||||
@ -25,15 +40,7 @@ function expect_img(image, expectedPixels)
|
|||||||
local value = image:getPixel(x, y)
|
local value = image:getPixel(x, y)
|
||||||
local expected = expectedPixels[1+y*w+x]
|
local expected = expectedPixels[1+y*w+x]
|
||||||
if value ~= expected then
|
if value ~= expected then
|
||||||
print('Image(' .. tostring(w) .. 'x' .. tostring(h) .. ') = {')
|
dump_img(image)
|
||||||
for v=0,h-1 do
|
|
||||||
lineStr = ' '
|
|
||||||
for u=0,w-1 do
|
|
||||||
lineStr = lineStr .. image:getPixel(u, v) .. ','
|
|
||||||
end
|
|
||||||
print(lineStr)
|
|
||||||
end
|
|
||||||
print('}')
|
|
||||||
print('In pixel (' .. x .. ', ' .. y .. '):')
|
print('In pixel (' .. x .. ', ' .. y .. '):')
|
||||||
|
|
||||||
local a = value
|
local a = value
|
||||||
@ -51,7 +58,7 @@ function expect_img(image, expectedPixels)
|
|||||||
app.pixelColor.rgbaG(b),
|
app.pixelColor.rgbaG(b),
|
||||||
app.pixelColor.rgbaB(b),
|
app.pixelColor.rgbaB(b),
|
||||||
app.pixelColor.rgbaA(b)))
|
app.pixelColor.rgbaA(b)))
|
||||||
elseif image.ColorMode == ColorMode.GRAY then
|
elseif image.colorMode == ColorMode.GRAY then
|
||||||
print(string.format(' - Value A = gray(%d,%d)',
|
print(string.format(' - Value A = gray(%d,%d)',
|
||||||
app.pixelColor.grayG(a),
|
app.pixelColor.grayG(a),
|
||||||
app.pixelColor.grayA(a)))
|
app.pixelColor.grayA(a)))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (C) 2019 Igara Studio S.A.
|
-- Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
--
|
--
|
||||||
-- This file is released under the terms of the MIT license.
|
-- This file is released under the terms of the MIT license.
|
||||||
-- Read LICENSE.txt for more information.
|
-- Read LICENSE.txt for more information.
|
||||||
@ -552,3 +552,70 @@ do
|
|||||||
expect_img(cel.image, { 0, 0,
|
expect_img(cel.image, { 0, 0,
|
||||||
0, 0 })
|
0, 0 })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
-- draw with tiled mode + image brush
|
||||||
|
-- test for: https://community.aseprite.org/t/tile-mode-glitch/1183
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
function drawing_with_tiled_mode_and_image_brush()
|
||||||
|
print("drawing_with_tiled_mode_and_image_brush")
|
||||||
|
local spr = Sprite(8, 3, ColorMode.INDEXED)
|
||||||
|
local cel = spr.cels[1]
|
||||||
|
|
||||||
|
-- enable tiled mode
|
||||||
|
local pref = app.preferences
|
||||||
|
local docPref = pref.document(spr)
|
||||||
|
docPref.tiled.mode = 3 -- both
|
||||||
|
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0 })
|
||||||
|
|
||||||
|
-- Create brush
|
||||||
|
local brushImg = Image(5, 2, ColorMode.INDEXED)
|
||||||
|
array_to_pixels({ 1, 2, 3, 2, 1,
|
||||||
|
0, 1, 2, 1, 0 }, brushImg)
|
||||||
|
local bru = Brush { image=brushImg }
|
||||||
|
|
||||||
|
-- Without overflow
|
||||||
|
app.useTool{ tool=pencil, brush=bru, points={ Point(2, 1) } }
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 1, 2, 3, 2, 1,
|
||||||
|
0, 1, 2, 1, 0 })
|
||||||
|
app.undo()
|
||||||
|
|
||||||
|
-- Overflow at the left-side
|
||||||
|
app.useTool{ tool=pencil, brush=bru, points={ Point(1, 1) } }
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 2, 3, 2, 1, 0, 0, 0, 1,
|
||||||
|
1, 2, 1, 0, 0, 0, 0, 0 })
|
||||||
|
app.undo()
|
||||||
|
|
||||||
|
-- Overflow at the right-side
|
||||||
|
app.useTool{ tool=pencil, brush=bru, points={ Point(9, 1) } }
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 2, 3, 2, 1, 0, 0, 0, 1,
|
||||||
|
1, 2, 1, 0, 0, 0, 0, 0 })
|
||||||
|
app.undo()
|
||||||
|
|
||||||
|
-- Overflow at the top
|
||||||
|
app.useTool{ tool=pencil, brush=bru, points={ Point(0, 0) } }
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 2, 1, 0, 0, 0, 0, 0, 1,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
3, 2, 1, 0, 0, 0, 1, 2 })
|
||||||
|
app.undo()
|
||||||
|
|
||||||
|
-- Overflow at the bottom
|
||||||
|
app.useTool{ tool=pencil, brush=bru, points={ Point(1, 3) } }
|
||||||
|
expect_img(cel.image,
|
||||||
|
{ 1, 2, 1, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
2, 3, 2, 1, 0, 0, 0, 1 })
|
||||||
|
app.undo()
|
||||||
|
|
||||||
|
docPref.tiled.mode = 0 -- none (disable tiled mode)
|
||||||
|
end
|
||||||
|
drawing_with_tiled_mode_and_image_brush()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user