Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #430 // makeIcon

Lua code

get("#348") -- rgb functions

function makeIcon(img)
  local x, y, w, h = 0, 0, img.width, img.height -- full image
  
  lines = {}
  for yy=y, y+h-1 do
    local line = {}
    for xx=x, x+w-1 do
      pix = img.getInt(xx, yy)
      b = math.floor(bright(rgb(pix))*25+0.5)
      table.insert(line, string.char(string.byte("A")+b))
    end
    table.insert(lines, table.concat(line))
  end
  return table.concat(lines, ".")
end

Author comment

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: #430
Snippet name: makeIcon
Eternal ID of this version: #430/1
Text MD5: 45de641a3bc7cca082dab6523ac5bf4c
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-02-08 14:47:55
Source code size: 442 bytes / 17 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 754 / 251
Referenced in: #429 - LXTerminal character reference maker 2
#432 - LXTerminal Contents Recognizer 2
#434 - LXTerminal Cursor Finder 2
#437 - LXTerminal Contents Recognizer 2 (cursor line only)
#438 - LXTerminal Contents Recognizer 2 (repeatable)
#439 - LXTerminal Contents Recognizer 2 (cursor line only, repeatable)
#440 - LXTerminal Cursor Finder 2 (repeatable)
#453 - Java character reference maker
#455 - Java source recognizer
#456 - Java character reference maker (non-bold)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)