module Draw.Color.Schemes.Discrete (
mma
, mathematica97
, accent
, dark2
, paired
, pastel1
, pastel2
, set1
, set2
, set3
) where
import Data.Vector (Vector, (!), (!?))
import qualified Data.Vector as V
import Draw.Color
import Draw.Color.Schemes.Internal.Common
import qualified Draw.Color.Schemes.Internal.ColorBrewer2 as ColorBrewer2
mma :: Int -> Color Double
mma :: Int -> Color Double
mma Int
i = case Vector (Color Double)
mma97cache Vector (Color Double) -> Int -> Maybe (Color Double)
forall a. Vector a -> Int -> Maybe a
!? Int
i of
Just Color Double
cached -> Color Double
cached
Maybe (Color Double)
Nothing -> RGB -> Color Double
toColor (Int -> RGB
generateMathematica97 Int
i)
{-# DEPRECATED mathematica97 "Renamed to mma" #-}
mathematica97 :: Int -> Color Double
mathematica97 :: Int -> Color Double
mathematica97 = Int -> Color Double
mma
generateMathematica97 :: Int -> RGB
generateMathematica97 :: Int -> RGB
generateMathematica97 Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = [Char] -> RGB
forall a. HasCallStack => [Char] -> a
error ([Char]
"mathematica97 color index out of bounds: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show Int
i)
generateMathematica97 Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
10 = Vector RGB
mma97_constantBeginning Vector RGB -> Int -> RGB
forall a. Vector a -> Int -> a
! Int
i
generateMathematica97 Int
i =
let (Integer
_, Double
i') = Double -> (Integer, Double)
forall b. Integral b => Double -> (b, Double)
forall a b. (RealFrac a, Integral b) => a -> (b, a)
properFraction (Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
10) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
goldenRatio)
goldenRatio :: Double
goldenRatio = (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double -> Double
forall a. Floating a => a -> a
sqrt Double
5)Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
2
in Vector RGB -> Double -> RGB
cyclic Vector RGB
mma97_interpolating Double
i'
mma97cache :: Vector (Color Double)
mma97cache :: Vector (Color Double)
mma97cache = Int -> (Int -> Color Double) -> Vector (Color Double)
forall a. Int -> (Int -> a) -> Vector a
V.generate Int
32 (\Int
i -> RGB -> Color Double
toColor (Int -> RGB
generateMathematica97 Int
i))
mma97_constantBeginning :: Vector RGB
mma97_constantBeginning :: Vector RGB
mma97_constantBeginning = [RGB] -> Vector RGB
forall a. [a] -> Vector a
V.fromList
[ Double -> Double -> Double -> RGB
RGB Double
0.368417 Double
0.506779 Double
0.709798
, Double -> Double -> Double -> RGB
RGB Double
0.880722 Double
0.611041 Double
0.142051
, Double -> Double -> Double -> RGB
RGB Double
0.560181 Double
0.691569 Double
0.194885
, Double -> Double -> Double -> RGB
RGB Double
0.922526 Double
0.385626 Double
0.209179
, Double -> Double -> Double -> RGB
RGB Double
0.528488 Double
0.470624 Double
0.701351
, Double -> Double -> Double -> RGB
RGB Double
0.772079 Double
0.431554 Double
0.102387
, Double -> Double -> Double -> RGB
RGB Double
0.363898 Double
0.618501 Double
0.782349
, Double -> Double -> Double -> RGB
RGB Double
1 Double
0.75 Double
0
, Double -> Double -> Double -> RGB
RGB Double
0.647624 Double
0.37816 Double
0.614037
, Double -> Double -> Double -> RGB
RGB Double
0.571589 Double
0.586483 Double
0
]
mma97_interpolating :: Vector RGB
mma97_interpolating :: Vector RGB
mma97_interpolating = [RGB] -> Vector RGB
forall a. [a] -> Vector a
V.fromList
[ Double -> Double -> Double -> RGB
RGB Double
0.915 Double
0.3325 Double
0.2125
, Double -> Double -> Double -> RGB
RGB Double
0.83 Double
0.46 Double
0
, Double -> Double -> Double -> RGB
RGB Double
0.9575 Double
0.545 Double
0.11475
, Double -> Double -> Double -> RGB
RGB Double
1 Double
0.7575 Double
0
, Double -> Double -> Double -> RGB
RGB Double
0.6175 Double
0.715 Double
0
, Double -> Double -> Double -> RGB
RGB Double
0.15 Double
0.715 Double
0.595
, Double -> Double -> Double -> RGB
RGB Double
0.3625 Double
0.545 Double
0.85
, Double -> Double -> Double -> RGB
RGB Double
0.575 Double
0.4175 Double
0.85
, Double -> Double -> Double -> RGB
RGB Double
0.677 Double
0.358 Double
0.595
, Double -> Double -> Double -> RGB
RGB Double
0.7875 Double
0.358 Double
0.425
, Double -> Double -> Double -> RGB
RGB Double
0.915 Double
0.3325 Double
0.2125
]
accent :: Int -> Color Double
accent :: Int -> Color Double
accent = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Accent
set1 :: Int -> Color Double
set1 :: Int -> Color Double
set1 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Set1
set2 :: Int -> Color Double
set2 :: Int -> Color Double
set2 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Set2
set3 :: Int -> Color Double
set3 :: Int -> Color Double
set3 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Set3
dark2 :: Int -> Color Double
dark2 :: Int -> Color Double
dark2 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Dark2
paired :: Int -> Color Double
paired :: Int -> Color Double
paired = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Paired
pastel2 :: Int -> Color Double
pastel2 :: Int -> Color Double
pastel2 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Pastel2
pastel1 :: Int -> Color Double
pastel1 :: Int -> Color Double
pastel1 = RGB -> Color Double
toColor (RGB -> Color Double) -> (Int -> RGB) -> Int -> Color Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector RGB -> Int -> RGB
discreteCyclic Vector RGB
ColorBrewer2.qualitative_Pastel1