get("#388") -- rect functions get("#348") -- rgb functions get("#356") -- num2hex function findContents() hashes = otherresults["#442"] or error("Need result of #442, please recalc") j, icons = nil, {} while true do i, j, r, hash = string.find(hashes, "(%d+, %d+, %d+, %d+) %-> ([a-f0-9]+)", j) if i == nil then break end icons[hash] = r end r = icons["00645074"] or icons["0061777a"] if r == nil then return "LXTerminal icon not found" end -- look for a mostly black line below the icon r = stringtorect(r) x, y = r.x, r.y contents_y1 = nil while y < img.height and contents_y1 == nil do w = 50 b = 0 for xx = x, x+w-1 do b = b+bright(rgb(img.getInt(xx, y))) end b = b/w --print("Brightness at", y, ":", b) if b < 0.01 then contents_y1 = y end y = y+1 end if contents_y1 == nil then return "Terminal contents not found" end -- find left side of contents contents_x1 = x while contents_x1 > 0 and img.getInt(contents_x1-1, contents_y1) == 0 do contents_x1 = contents_x1-1 end -- find width of contents while x < img.width and img.getInt(x, contents_y1) == 0 do x = x+1 end contents_x2 = x-1 -- find bottom of contents y = contents_y1+1 while y < img.height and (img.getInt(contents_x1, y) ~= 0xa4a4a4 or img.getInt(contents_x1+1, y) ~= 0xa4a4a4) do --print("y", y, num2hex(img.getInt(contents_x1, y)), num2hex(img.getInt(contents_x1+1, y))) y = y+1 end contents_y2 = y contents_y1 = contents_y1+1 end
Began life as a copy of #424
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment