Factored out default color selection in getIndividualColor to eliminate code duplication.
authorsabadev <saba@sabadev.xyz>
Sun, 21 Mar 2021 04:35:34 +0000 (00:35 -0400)
committersabadev <dev@sabadev.xyz>
Tue, 13 Apr 2021 01:16:31 +0000 (21:16 -0400)
src/Server.hs

index c3d0fbe..e2897ee 100644 (file)
@@ -51,5 +51,8 @@ getColorFromInput lightDark redColor greenColor blueColor = do
   C.rgba red green blue 1
 
 getIndividualColor :: LightDark -> Maybe Integer -> Integer
-getIndividualColor Dark value = flip mod 0x100 $ fromMaybe 0x00 value
-getIndividualColor Light value = flip mod 0x100 $ fromMaybe 0xFF value
+getIndividualColor color = flip mod 0x100 . fromMaybe (defaultColor color)
+
+defaultColor :: LightDark -> Integer
+defaultColor Dark = 0x00
+defaultColor Light = 0xFF