change to exact rgba comparison for visual tests

This commit is contained in:
ell
2023-11-17 00:11:32 +00:00
parent d1307584e5
commit a8c714bc89
2 changed files with 8 additions and 22 deletions
+6 -15
View File
@@ -273,29 +273,20 @@ TestMethod = {
)
local iw = imgdata:getWidth()-2
local ih = imgdata:getHeight()-2
local tolerance = 0 -- @NOTE could pass in optional tolerance i.e. 1/255
for ix=2,iw do
for iy=2,ih do
local ir, ig, ib, ia = imgdata:getPixel(ix, iy)
local tolerance = {
{expected:getPixel(ix, iy)},
{expected:getPixel(ix+1, iy+1)},
{expected:getPixel(ix+1, iy)},
{expected:getPixel(ix+1, iy-1)},
{expected:getPixel(ix, iy+1)},
{expected:getPixel(ix, iy-1)},
{expected:getPixel(ix-1, iy+1)},
{expected:getPixel(ix-1, iy)},
{expected:getPixel(ix-1, iy-1)}
}
local er, eg, eb, ea = expected:getPixel(ix, iy)
local has_match_r = false
local has_match_g = false
local has_match_b = false
local has_match_a = false
for t=1,9 do
if ir == tolerance[t][1] then has_match_r = true; end
if ig == tolerance[t][2] then has_match_g = true; end
if ib == tolerance[t][3] then has_match_b = true; end
if ia == tolerance[t][4] then has_match_a = true; end
if ir >= er - tolerance and ir <= er + tolerance then has_match_r = true; end
if ig >= eg - tolerance and ig <= eg + tolerance then has_match_g = true; end
if ib >= eb - tolerance and ib <= eb + tolerance then has_match_b = true; end
if ia >= ea - tolerance and ia <= ea + tolerance then has_match_a = true; end
end
local matching = has_match_r and has_match_g and has_match_b and has_match_a
local ymatch = ''