1 | go("#137") -- split
|
2 | |
3 | _, _, s = string.find(result, ": (.+)") |
4 | parts = split(s, ", ") |
5 | |
6 | -- copy image |
7 | |
8 | w, h = img.width, img.height |
9 | pixels = {}
|
10 | for y = 0, h-1 do |
11 | for x = 0, w-1 do |
12 | pixels[y*w+x+1] = img.getInt(x, y) |
13 | end |
14 | end |
15 | |
16 | -- invert the segments |
17 | |
18 | for _, segment in ipairs(parts) do |
19 | x1, x2 = unpack(split(segment, "-")) |
20 | for x = x1, x2-1 do |
21 | for y = 0, h-1 do |
22 | pixels[y*w+x+1] = 0xFFFFFF - pixels[y*w+x+1] |
23 | end |
24 | end |
25 | end |
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: | #338 |
| Snippet name: | Horizontal Segments Visualizer |
| Eternal ID of this version: | #338/1 |
| Text MD5: | 5c7d315b664df748438ae9237ec99281 |
| 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-03 21:27:44 |
| Source code size: | 463 bytes / 25 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 879 / 217 |
| Referenced in: | [show references] |