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
|
# File 'lib/rspec-framework-led-matrix/image_generator.rb', line 5
def self.generate_image(statuses)
width = 9
height = 34
passed_points = []
pending_points = []
statuses.each_with_index do |status, idx|
x = idx % width
y = idx / width
case status
when :passed
passed_points << "point #{x},#{y}"
when :pending
pending_points << "point #{x},#{y}"
end
end
draw_params = []
draw_params << "-fill gray10 -draw \"#{pending_points.join(" ")}\"" unless pending_points.empty?
draw_params << "-fill white -draw \"#{passed_points.join(" ")}\"" unless passed_points.empty?
command = [
"convert",
"-size #{width}x#{height}",
"xc:black",
draw_params.join(" "),
"output.png"
].join(" ")
system(command)
end
|