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

17
LINES

< > BotCompany Repo | #430 // makeIcon

Lua code

1  
get("#348") -- rgb functions
2  
3  
function makeIcon(img)
4  
  local x, y, w, h = 0, 0, img.width, img.height -- full image
5  
  
6  
  lines = {}
7  
  for yy=y, y+h-1 do
8  
    local line = {}
9  
    for xx=x, x+w-1 do
10  
      pix = img.getInt(xx, yy)
11  
      b = math.floor(bright(rgb(pix))*25+0.5)
12  
      table.insert(line, string.char(string.byte("A")+b))
13  
    end
14  
    table.insert(lines, table.concat(line))
15  
  end
16  
  return table.concat(lines, ".")
17  
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: 755 / 252
Referenced in: [show references]