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
|
# File 'lib/boring_avatars/variants/marble.rb', line 18
def render(input:, hash:, ids:)
properties = Array.new(ELEMENTS) do |index|
multiplier = index + 1
{
color: Utilities.random_color(hash + index, input.colors),
translate_x: Utilities.unit(hash * multiplier, SIZE / 10, 1),
translate_y: Utilities.unit(hash * multiplier, SIZE / 10, 2),
scale: 1.2 + (Utilities.unit(hash * multiplier, SIZE / 20) / 10.0),
rotate: Utilities.unit(hash * multiplier, 360, 1)
}
end
content = [
element("rect", { "width" => SIZE, "height" => SIZE, "fill" => properties[0][:color] }),
element(
"path",
{
"filter" => "url(##{ids[:filter]})",
"d" => FIRST_PATH,
"fill" => properties[1][:color],
"transform" => transform(properties[1], properties[2][:scale])
}
),
element(
"path",
{
"filter" => "url(##{ids[:filter]})",
"style" => "mix-blend-mode:overlay",
"d" => SECOND_PATH,
"fill" => properties[2][:color],
"transform" => transform(properties[2], properties[2][:scale])
}
)
]
filter = element(
"filter",
{
"id" => ids[:filter],
"filterUnits" => "userSpaceOnUse",
"color-interpolation-filters" => "sRGB"
},
[
element("feFlood", { "flood-opacity" => 0, "result" => "BackgroundImageFix" }),
element(
"feBlend",
{ "in" => "SourceGraphic", "in2" => "BackgroundImageFix", "result" => "shape" }
),
element(
"feGaussianBlur",
{ "stdDeviation" => 7, "result" => "effect1_foregroundBlur" }
)
]
)
VariantResult.new(size: SIZE, content: content, defs: [filter])
end
|