splot 0.3.7 → 0.3.8
raw patch · 2 files changed
+6/−16 lines, 2 files
Files
- Tools/ColorMap.hs +5/−15
- splot.cabal +1/−1
Tools/ColorMap.hs view
@@ -29,7 +29,7 @@ prepareColorMap :: [(S.ByteString, [S.ByteString])] -> ColorMap prepareColorMap ms = ColorMap $ M.fromList $ (S.pack "", defaultColorMap):- [(scheme, ColorMap1 M.empty $ cycle $ map (fromJust . readColor) colorNames) | (scheme, colorNames) <- ms]+ [(scheme, ColorMap1 M.empty $ cycle $ map (toSRGB . fromJust . readColor . S.unpack) colorNames) | (scheme, colorNames) <- ms] -- | Starts with empty names-colors map and mid-range grey defaultColorMap = ColorMap1 M.empty defaultColorWheel@@ -47,22 +47,12 @@ -- -- * Otherwise, the @color@ name is looked up in the @map@ and if it is not found, a new color is generated -- using a simple cycling function.-computeColor map color = case readColor color of +computeColor map color = case readColor (S.unpack color) of Nothing -> cycleColor map color- Just c -> (c, map)- -readColor = readColor' . S.unpack--readColor' ('#':r1:r2:g1:g2:b1:b2:[]) = Just (RGB r g b)- where- r = fromIntegral $ unhex r2 + 16*unhex r1- g = fromIntegral $ unhex g2 + 16*unhex g1- b = fromIntegral $ unhex b2 + 16*unhex b1- unhex c | c >= '0' && c <= '9' = fromEnum c - fromEnum '0'- | c >= 'a' && c <= 'z' = 10 + fromEnum c - fromEnum 'a'- | c >= 'A' && c <= 'Z' = 10 + fromEnum c - fromEnum 'A'-readColor' cs = toSRGB `fmap` readColourName cs+ Just c -> (toSRGB c, map) +readColor cs@('#':_) = Just (sRGB24read cs)+readColor cs = readColourName cs cycleColor :: ColorMap -> S.ByteString
splot.cabal view
@@ -1,5 +1,5 @@ Name: splot-Version: 0.3.7+Version: 0.3.8 License: BSD3 License-file: LICENSE Copyright: Eugene Kirpichov, 2010