aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Color.elm
diff options
context:
space:
mode:
authorJoris2015-11-15 19:20:42 +0100
committerJoris2015-11-15 19:20:42 +0100
commit4710e5ac30c44ca8b48a0b2b60ea74b1573b084b (patch)
treedb2c1700de3352e2ec73b5f1e41e7d0452489291 /src/Model/Color.elm
parent1beb59f73bc18b2477cf1eb918ff75b8d6282c5a (diff)
Add levels which only change the board color every 20 points
Diffstat (limited to 'src/Model/Color.elm')
-rw-r--r--src/Model/Color.elm22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Model/Color.elm b/src/Model/Color.elm
new file mode 100644
index 0000000..8452efa
--- /dev/null
+++ b/src/Model/Color.elm
@@ -0,0 +1,22 @@
+module Model.Color
+ ( Color
+ , htmlOutput
+ , mergeColors
+ ) where
+
+type alias Color =
+ { red : Int
+ , green : Int
+ , blue : Int
+ }
+
+htmlOutput : Color -> String
+htmlOutput color = "rgb(" ++ (toString color.red) ++ ", " ++ (toString color.green) ++ ", " ++ (toString color.blue) ++ ")"
+
+mergeColors : Float -> Color -> Color -> Color
+mergeColors ratio c1 c2 =
+ let mergePart x y = truncate (ratio * (toFloat x) + (1 - ratio) * (toFloat y))
+ in { red = mergePart c1.red c2.red
+ , green = mergePart c1.green c2.green
+ , blue = mergePart c1.blue c2.blue
+ }