Last active
December 20, 2015 14:58
-
-
Save melrief/6150234 to your computer and use it in GitHub Desktop.
Create a list of very different colors using http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Colour.RGBSpace.HSV (RGB, hsv) | |
nextColor :: (RealFrac a) => a -> a -> a -> (RGB a,a) | |
nextColor h s v = let h' = (h + golden_ratio_conjugate) % 360 | |
in (hsv h' s v,h') | |
where golden_ratio_conjugate = 222.4922359499622 -- 0.618033988749895 * 360 | |
dividend % divisor = dividend - divisor * | |
(fromIntegral $ floor (dividend/divisor)) | |
goldenColors :: (RealFrac a) => a -> a -> a -> [RGB a] | |
goldenColors h s v = let (c,h') = nextColor h s v | |
in c:goldenColors h' s v | |
-- note: to use a HSV.RBG value as Color you can convert it using uncurryRGB sRGB color3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment