aboutsummaryrefslogtreecommitdiff
path: root/src/Utils/Color.elm
diff options
context:
space:
mode:
authorJoris2016-10-03 20:24:59 +0200
committerJoris2016-10-03 20:24:59 +0200
commit2a11b28d2ee636eb730dbb5767104aeac9936afa (patch)
treec7261376073d9334007d24fbe67acda6e11943fa /src/Utils/Color.elm
parentc79aae101926d3e5a123b707dd1324dca50994b7 (diff)
parent3a1cbfe23a3d06c3c30828c623a089868cff0670 (diff)
Merge branch 'master' into demo
Diffstat (limited to 'src/Utils/Color.elm')
-rw-r--r--src/Utils/Color.elm23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Utils/Color.elm b/src/Utils/Color.elm
new file mode 100644
index 0000000..f9e344f
--- /dev/null
+++ b/src/Utils/Color.elm
@@ -0,0 +1,23 @@
+module Utils.Color exposing
+ ( merge
+ , spin
+ )
+
+import Color as Color exposing (Color)
+
+merge : Float -> Color -> Color -> Color
+merge ratio c1 c2 =
+ let rgb1 = Color.toRgb c1
+ rgb2 = Color.toRgb c2
+ mergePartFloat x y = ratio * x + (1 - ratio) * y
+ mergePartInt x y = truncate <| ratio * (toFloat x) + (1 - ratio) * (toFloat y)
+ in Color.rgba
+ (mergePartInt rgb1.red rgb2.red)
+ (mergePartInt rgb1.green rgb2.green)
+ (mergePartInt rgb1.blue rgb2.blue)
+ (mergePartFloat rgb1.alpha rgb2.alpha)
+
+spin : Float -> Color -> Color
+spin d color =
+ let { hue, saturation, lightness, alpha } = Color.toHsl color
+ in Color.hsla (hue + degrees d) saturation lightness alpha