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
|
# File 'lib/avatar_generator/renderer.rb', line 5
def self.render(image)
background = ChunkyPNG::Color.from_hex(image.background)
png = ChunkyPNG::Image.new(
image.image_size,
image.image_size,
background
)
color = ChunkyPNG::Color.rgb(
*image.color
)
image.pixel_map.each do |rectangle|
top_left,
bottom_right = rectangle
x1, y1 = top_left
x2, y2 = bottom_right
(x1..x2).each do |x|
(y1..y2).each do |y|
png[x, y] = color
end
end
end
png
end
|