get("#348") -- rgb functions function stringRepImage(img) local x, y, w, h = 0, 0, img.width, img.height -- full image local tbl = {} for yy=y, y+h-1 do if yy > y then table.insert(tbl, ".") end for xx=x, x+w-1 do local pix = img.getInt(xx, yy) local b = math.floor(bright(rgb(pix))*25+0.5) table.insert(tbl, string.char(string.byte("A")+b)) end end return table.concat(tbl) end
Began life as a copy of #382
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
Snippet ID: | #417 |
Snippet name: | stringRepImage (include) |
Eternal ID of this version: | #417/1 |
Text MD5: | a715f76dce5a4caa8d4aa4a9b269d0e6 |
Author: | stefan |
Category: | |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-06 14:03:45 |
Source code size: | 435 bytes / 16 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 725 / 211 |
Referenced in: | #418 - Grid + Floodfill with string rep #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |