mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Add array_to_pixels() to test_utils.lua
This commit is contained in:
parent
4f33bd8e14
commit
6c0523f150
@ -16,6 +16,10 @@ 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
|
||||||
|
print(debug.traceback())
|
||||||
|
assert(w*h == #expectedPixels)
|
||||||
|
end
|
||||||
for y=0,h-1 do
|
for y=0,h-1 do
|
||||||
for x=0,w-1 do
|
for x=0,w-1 do
|
||||||
local value = image:getPixel(x, y)
|
local value = image:getPixel(x, y)
|
||||||
@ -63,3 +67,16 @@ function expect_img(image, expectedPixels)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function array_to_pixels(array, image)
|
||||||
|
local w = image.width
|
||||||
|
local h = image.height
|
||||||
|
assert(w*h == #array)
|
||||||
|
local i = 1
|
||||||
|
for y=0,h-1 do
|
||||||
|
for x=0,w-1 do
|
||||||
|
image:drawPixel(x, y, array[i])
|
||||||
|
i = i+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user