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: 753 / 251
Referenced in: [show references]