-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.lua
More file actions
109 lines (81 loc) · 2.38 KB
/
tests.lua
File metadata and controls
109 lines (81 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
local P1 = require('./src/P1')
local P2 = require('./src/P2')
local P3 = require('./src/P3')
extensions = {'pbm','pgm','ppm'}
image = {}
image[1] = {
1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 0, 0, 1, 1, 0, 0, 1, 1,
1, 0, 0, 1, 1, 0, 0, 1, 1,
1, 1, 1, 0, 0, 1, 1, 1, 1,
1, 1, 1, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1
}
image[2] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8, 9,
2, 3, 4, 5, 6, 7, 8, 9, 10,
3, 4, 5, 6, 7, 8, 9, 10, 11,
4, 5, 6, 7, 8, 9, 10, 11, 12,
5, 6, 7, 8, 9, 10, 11, 12, 13,
6, 7, 8, 9, 10, 11, 12, 13, 14,
7, 8, 9, 10, 11, 12, 13, 14, 15,
8, 9, 10, 11, 12, 13, 14, 15, 16
}
image[3] = {
255, 0, 0, 0, 255, 0, 0, 0, 255,
255, 0, 0, 0, 255, 0, 0, 0, 255
}
size = {{ 9, 9, nil}, { 9, 9, 16}, {3, 2, 255}}
Ps = {}
for i = 1, 3 do
if i == 1 then
Ps[1] = P1:new('imageP'..tostring(i), '# {-_-}', size[i][1], size[i][2])
elseif i == 2 then
Ps[2] = P2:new('imageP'..tostring(i), '# {-_-}', size[i][1], size[i][2], size[i][3])
else
Ps[3] = P3:new('imageP'..tostring(i), '# {-_-}', size[i][1], size[i][2], size[i][3])
end
print('\nimageP' .. i .. '.' .. extensions[i] .. ' === === === === === ===\n')
-- images
images = Ps[i]
for j = 0, 2 do
if i ~= 2 then
images:draw( j, image[i])
print(images:mount_image())
print('\n')
elseif j ~= 2 then
images:draw( j, image[i])
print(images:mount_image())
print('\n')
end
end
arquivo_image= io.open(images.name, 'w')
arquivo_image:write(images:mount_image())
arquivo_image:close()
end
a = P1:new('imageP1-0', '# {-_-}', 9, 9)
a:draw(2, {
1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 0, 0, 1, 1, 0, 0, 1, 1,
1, 0, 0, 1, 1, 0, 0, 1, 1,
1, 1, 1, 0, 0, 1, 1, 1, 1,
1, 1, 1, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
})
arquivo_image= io.open(a.name, 'w')
arquivo_image:write(a:mount_image())
arquivo_image:close()
a:drawTerminal("imageP1-0.pbm")
local function ansiRGB(_table)
local red = (_table[1] or 0) * 255
local green = (_table[2] or 0) * 255
local blue = (_table[3] or 0) * 255
return ("\27[48;2;%d;%d;%dm"):format(red, green, blue)
end