packages feed

palette 0.3 → 0.3.0.1

raw patch · 3 files changed

+29/−12 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

CHANGES.markdown view
@@ -1,3 +1,16 @@+0.3.0.1 (8 May 2018)+--------------------++- Allow base-4.11+- Warning fixes++0.3 (30 April 2018)+-------------------++- New module Data.Colour.Palette.RandomColor, for making random+  choices of colors and palettes+- New colorRamp function+ 0.1.0.5-r1 (23 Sep 2017) ------------------------ 
palette.cabal view
@@ -1,5 +1,5 @@ Name:                palette-Version:             0.3+Version:             0.3.0.1 Synopsis:            Utilities for choosing and creating color schemes. Description:         Sets of predefined colors and tools for choosing and                      creating color schemes. Random colors.@@ -15,7 +15,7 @@ Cabal-version:       >=1.18 Extra-source-files:  README.markdown, CHANGES.markdown, diagrams/*.svg Extra-doc-files:     diagrams/*.svg-Tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1, GHC == 8.2.1+Tested-with:         GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1, GHC == 8.2.2, GHC == 8.4.2 Source-repository head   type:     git   location: http://github.com/diagrams/palette.git@@ -28,7 +28,7 @@                        Data.Colour.Palette.Types                        Data.Colour.Palette.RandomColor -  Build-depends:       base >= 4.2 && < 4.11,+  Build-depends:       base >= 4.2 && < 4.12,                        array >= 0.4 && < 0.6,                        colour >= 2.3 && <3.0,                        containers >= 0.5 && < 0.6,
src/Data/Colour/Palette/RandomColor.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE LambdaCase #-}++{-# OPTIONS_GHC -fno-warn-name-shadowing #-} ----------------------------------------------------------------------------- -- | -- Module      :  Palette.RandomColor@@ -32,9 +34,8 @@   ) where  import           Control.Monad.Random-import           Data.Colour-import           Data.Colour.CIE-import           Data.Colour.CIE.Illuminant+import           Data.Colour.CIE            (cieLAB)+import           Data.Colour.CIE.Illuminant (d65) import           Data.Colour.Palette.Harmony import           Data.Colour.Palette.Types import           Data.Colour.RGBSpace.HSV@@ -85,10 +86,11 @@   | n' >= 47  = HueYellow   | n' >= 19  = HueOrange   | n' >= -26 = HueRed+  | otherwise = error "getHue: hue outside [0, 360]"   where     n' = if n >= 334 && n <= 360 then n - 360 else n --- | return a random hue in the range [lo, hi] as a 'Double'.+-- | Return a random hue in the range $[lo, hi]$ as a 'Double'. --   lo should be >= 0 and hi < 360. --   Instead of storing red as two seperate ranges we create a single --   contiguous range using negative numbers.@@ -106,12 +108,13 @@     lbs = lowerBounds $ getColorDefinition hue     result = case lbs of       [] -> error "Can\'t obtain saturationRange from an empty lowerBounds"-      xs -> (fst . head $ lbs, fst . last $ lbs)+      _  -> (fst . head $ lbs, fst . last $ lbs)  randomSaturation :: MonadRandom m => Hue -> Luminosity -> m Int-randomSaturation HueMonochrome _         = return 0-randomSaturation _             LumRandom = getRandomR (0, 100)-randomSaturation hue           lum       = case lum of+randomSaturation HueMonochrome _   = return 0++randomSaturation hue           lum = case lum of+  LumRandom -> getRandomR (0, 100)   LumBright -> getRandomR (55, hi)   LumDark   -> getRandomR (hi - 10, hi)   LumLight  -> getRandomR (lo, 55)@@ -124,8 +127,9 @@     lbs = lowerBounds $ getColorDefinition hue     tup a  = zip (0:a) a     inRange j (k, n) = j >= k && j <= n+    result :: Maybe Double     result = do-      (s1, s2) <- find (inRange saturationValue) (tup $ fst <$> lbs)+      (s1, s2) <- find (inRange saturationValue) (tup $ fmap fst lbs)       v1       <- lookup s1 lbs       v2       <- lookup s2 lbs       let m = fromIntegral (v2 - v1) / fromIntegral (s2 -s1)