Skip to content

Commit 0cd3204

Browse files
committed
Pick the color
1 parent d224108 commit 0cd3204

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/identicon.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule Identicon do
99
def main(input) do
1010
input
1111
|> hash_input()
12+
|> pick_color()
1213
end
1314

1415
@doc """
@@ -21,4 +22,8 @@ defmodule Identicon do
2122

2223
%Identicon.Image{hex: hex}
2324
end
25+
26+
def pick_color(%Identicon.Image{hex: [r, g, b | _rest]} = image) do
27+
%Identicon.Image{image | color: {r, g, b}}
28+
end
2429
end

lib/image.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ defmodule Identicon.Image do
33
Documentation for `Identicon.Image`.
44
"""
55

6-
defstruct hex: nil
6+
defstruct hex: nil,
7+
color: nil
78
end

0 commit comments

Comments
 (0)