23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/boring_avatars/variants/pixel.rb', line 23
def render(input:, hash:, ids:)
colors = Array.new(ELEMENTS) do |index|
Utilities.random_color(hash % (index + 1), input.colors)
end
content = COORDINATES.each_with_index.map do |(x, y), index|
element(
"rect",
{
"x" => x.zero? ? nil : x,
"y" => y.zero? ? nil : y,
"width" => 10,
"height" => 10,
"fill" => colors[index]
}
)
end
VariantResult.new(
size: SIZE,
content: content,
mask_attributes: { "mask-type" => "alpha" }
)
end
|