Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit 79d93e6

Browse files
authored
Merge pull request #305 from unisonweb/hashvatar-hue-tendrils
Hashvatar: use background hue for tendrils
2 parents 2251b15 + f125906 commit 79d93e6

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

src/Hashvatar.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ toGrid slots =
7171
selectTendrils grid_ =
7272
let
7373
tendrils =
74-
getIn grid_.tendrils (Color.harmonizesWith grid_.background)
74+
getIn grid_.tendrils (Color.inSameHue grid_.background)
7575
in
7676
Maybe.map
7777
(\tr ->

src/UI/Color.elm

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,98 @@ filterLuminance pred colors_ =
102102

103103

104104

105+
-- Hue
106+
107+
108+
type Hue
109+
= Gray
110+
| Orange
111+
| Pink
112+
| Purple
113+
| Blue
114+
| Green
115+
116+
117+
hueOf : Color -> Hue
118+
hueOf color =
119+
if isGray color then
120+
Gray
121+
122+
else if isOrange color then
123+
Orange
124+
125+
else if isPink color then
126+
Pink
127+
128+
else if isPurple color then
129+
Purple
130+
131+
else if isBlue color then
132+
Blue
133+
134+
else
135+
Green
136+
137+
138+
{-| Get all the other colors in the same hue as the given color
139+
-}
140+
inSameHue : Color -> List Color
141+
inSameHue color =
142+
let
143+
sameHue =
144+
case hueOf color of
145+
Gray ->
146+
grays
147+
148+
Orange ->
149+
oranges
150+
151+
Pink ->
152+
pinks
153+
154+
Purple ->
155+
purples
156+
157+
Blue ->
158+
blues
159+
160+
Green ->
161+
greens
162+
in
163+
List.filter (\c -> c /= color) sameHue
164+
165+
166+
isGray : Color -> Bool
167+
isGray color =
168+
List.member color grays
169+
170+
171+
isOrange : Color -> Bool
172+
isOrange color =
173+
List.member color oranges
174+
175+
176+
isPink : Color -> Bool
177+
isPink color =
178+
List.member color pinks
179+
180+
181+
isPurple : Color -> Bool
182+
isPurple color =
183+
List.member color purples
184+
185+
186+
isBlue : Color -> Bool
187+
isBlue color =
188+
List.member color blues
189+
190+
191+
isGreen : Color -> Bool
192+
isGreen color =
193+
List.member color greens
194+
195+
196+
105197
-- Grays
106198

107199

0 commit comments

Comments
 (0)