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

27
LINES

< > BotCompany Repo | #450 // Heat Map Visualizer (Vertical)

Lua code - Visualizer

1  
function setPixel(x, y, pix)
2  
  if x >= 0 and y >= 0 and x < w and y < h then
3  
    pixels[y*w+x+1] = pix
4  
  end
5  
end
6  
7  
-- copy image
8  
9  
w, h = img.width, img.height
10  
pixels = {}
11  
for y = 0, h-1 do
12  
  for x = 0, w-1 do
13  
    pixels[y*w+x+1] = img.getInt(x, y)
14  
  end
15  
end
16  
17  
-- iterate over heatmap
18  
19  
_, _, map = string.find(result, ": (.*)")
20  
21  
for y = 0, h-1 do
22  
  b = math.floor((string.byte(map, y+1)-string.byte("A"))*255/25+0.5)
23  
  for x = 0, 3 do
24  
    setPixel(x, y, b*0x010101)
25  
    setPixel(w-1-x, y, b*0x010101)
26  
  end
27  
end

Author comment

Began life as a copy of #367

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: #450
Snippet name: Heat Map Visualizer (Vertical)
Eternal ID of this version: #450/1
Text MD5: 8c45ab7730d92560fc3317a0f2ae8402
Author: stefan
Category: ir result visualizers
Type: Lua code - Visualizer
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-02-12 23:43:33
Source code size: 533 bytes / 27 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 723 / 177
Referenced in: [show references]