{-# LANGUAGE OverloadedStrings #-}
{-|
  A colormap takes a number between 0 and 1 (inclusive) and spits out a color.
  The colors do not have an alpha component but one can be added with
  `Codec.Picture.Types.promotePixel`.
-}
module Reanimate.ColorMap
  ( turbo
  , viridis
  , magma
  , inferno
  , plasma
  , sinebow
  , parula
  , cividis
  , jet
  , hsv
  , hsvMatlab
  , greyscale
  ) where

import           Codec.Picture            (Pixel8, PixelRGB8 (..))
import           Data.Bits                (Bits (shiftL))
import           Data.Char                (digitToInt)
import           Data.Colour.RGBSpace     (RGB (RGB))
import qualified Data.Colour.RGBSpace.HSV as HSV
import           Data.Text                (Text)
import qualified Data.Text                as T
import           Data.Vector              (Vector)
import qualified Data.Vector              as V

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “turbo” color scheme by Anton Mikhailov.
--
--   <<docs/gifs/doc_turbo.gif>>
turbo :: Double -> PixelRGB8
turbo :: Double -> PixelRGB8
turbo Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 Pixel8
red Pixel8
green Pixel8
blue
  where
    red :: Pixel8
red   = Integer -> Pixel8
trunc (Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round (Double
34.61 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
1172.33 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
10793.56 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
33300.12 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
38394.49 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
14825.05))))))
    green :: Pixel8
green = Integer -> Pixel8
trunc (Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round (Double
23.31 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
557.33 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
1225.33 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
3574.96 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
1073.77 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
707.56))))))
    blue :: Pixel8
blue  = Integer -> Pixel8
trunc (Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round (Double
27.2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
3211.1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
15327.97 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
27814 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
22569.18 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
6838.66))))))
    trunc :: Integer -> Pixel8
    trunc :: Integer -> Pixel8
trunc = Integer -> Pixel8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Pixel8) -> (Integer -> Integer) -> Integer -> Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
min Integer
255 (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
max Integer
0

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “viridis” perceptually-uniform color scheme designed by van der Walt,
--   Smith and Firing for matplotlib, represented as an RGB string.
--
--   <<docs/gifs/doc_viridis.gif>>
viridis :: Double -> PixelRGB8
viridis :: Double -> PixelRGB8
viridis = Vector PixelRGB8 -> Double -> PixelRGB8
ramp (Text -> Vector PixelRGB8
colors
  Text
"44015444025645045745055946075a46085c460a5d460b5e470d60470e614710634711644713\
  \6548146748166848176948186a481a6c481b6d481c6e481d6f481f7048207148217348237448\
  \2475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f\
  \463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142\
  \874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b\
  \518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d\
  \355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b\
  \8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a\
  \778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e\
  \25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f\
  \8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e\
  \9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a685\
  \22a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db2\
  \7d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340\
  \bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c765\
  \5ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d0\
  \5477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195\
  \d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2b\
  \b8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e2\
  \19dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8\
  \e621fbe723fde725")

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “magma” perceptually-uniform color scheme designed by van der Walt and
--   Smith for matplotlib, represented as an RGB string.
--
--   <<docs/gifs/doc_magma.gif>>
magma :: Double -> PixelRGB8
magma :: Double -> PixelRGB8
magma = Vector PixelRGB8 -> Double -> PixelRGB8
ramp (Text -> Vector PixelRGB8
colors
  Text
"00000401000501010601010802010902020b02020d03030f0303120404140504160605180605\
  \1a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d3414\
  \0e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e221150241253\
  \25125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f\
  \6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f\
  \127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980\
  \641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621\
  \817822817922827b23827c23827e24828025828125818326818426818627818827818928818b\
  \29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7f\
  \a02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb336\
  \7ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c8\
  \3e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476a\
  \dc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb57\
  \60ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf6\
  \6c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835f\
  \fb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b\
  \6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afe\
  \b47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8d\
  \fecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2\
  \a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fc\
  \f9bbfcfbbdfcfdbf")

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “inferno” perceptually-uniform color scheme designed by van der Walt
--   and Smith for matplotlib, represented as an RGB string.
--
--   <<docs/gifs/doc_inferno.gif>>
inferno :: Double -> PixelRGB8
inferno :: Double -> PixelRGB8
inferno = Vector PixelRGB8 -> Double -> PixelRGB8
ramp (Text -> Vector PixelRGB8
colors
  Text
"00000401000501010601010802010a02020c02020e0302100403120403140504170604190705\
  \1b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b3716\
  \0b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b55\
  \2b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a\
  \67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d55\
  \0f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e\
  \6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e\
  \6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f246990256892\
  \25689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60\
  \a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b935\
  \56ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb\
  \4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3c\
  \db503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee860\
  \2de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2\
  \741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890c\
  \f98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca1\
  \08fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfb\
  \ba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13d\
  \f7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea\
  \69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9\
  \fc9dfafda1fcffa4")

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “plasma” perceptually-uniform color scheme designed by van der Walt and
--   Smith for matplotlib, represented as an RGB string.
--
--   <<docs/gifs/doc_plasma.gif>>
plasma :: Double -> PixelRGB8
plasma :: Double -> PixelRGB8
plasma = Vector PixelRGB8 -> Double -> PixelRGB8
ramp (Text -> Vector PixelRGB8
colors
  Text
"0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05\
  \932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41\
  \049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a4\
  \5601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900\
  \a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d\
  \03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca4\
  \8f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a\
  \9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b0\
  \2991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786\
  \be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca45\
  \7acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5\
  \546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263\
  \e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e971\
  \58e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1\
  \814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143\
  \f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca3\
  \38fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efe\
  \b72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26\
  \fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df\
  \25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1\
  \f525f0f724f0f921")

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “sinebow” color scheme by Jim Bumgardner and Charlie Loyd.
--
--   <<docs/gifs/doc_sinebow.gif>>
sinebow :: Double -> PixelRGB8
sinebow :: Double -> PixelRGB8
sinebow Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 Pixel8
r Pixel8
g Pixel8
b
  where
    pi_1_3 :: Double
pi_1_3 = Double
forall a. Floating a => a
pi Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
3
    pi_2_3 :: Double
pi_2_3 = Double
forall a. Floating a => a
pi Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
3
    x :: Double
x = (Double
0.5 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t) Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
forall a. Floating a => a
pi
    r :: Pixel8
r = Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
255 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double -> Double
forall a. Floating a => a -> a
sin Double
xDouble -> Double -> Double
forall a. Floating a => a -> a -> a
**Double
2
    g :: Pixel8
g = Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
255 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double -> Double
forall a. Floating a => a -> a
sin (Double
xDouble -> Double -> Double
forall a. Num a => a -> a -> a
+Double
pi_1_3)Double -> Double -> Double
forall a. Floating a => a -> a -> a
**Double
2
    b :: Pixel8
b = Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
255 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double -> Double
forall a. Floating a => a -> a
sin (Double
xDouble -> Double -> Double
forall a. Num a => a -> a -> a
+Double
pi_2_3)Double -> Double -> Double
forall a. Floating a => a -> a -> a
**Double
2

-- | Given a number t in the range [0,1], returns the corresponding color from
--   the “cividis” color vision deficiency-optimized color scheme designed by
--   Nuñez, Anderton, and Renslow, represented as an RGB string.
--
--   <<docs/gifs/doc_cividis.gif>>
cividis :: Double -> PixelRGB8
cividis :: Double -> PixelRGB8
cividis Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 Pixel8
red Pixel8
green Pixel8
blue
  where
    red :: Pixel8
red   = Integer -> Pixel8
trunc (Integer -> Pixel8) -> Integer -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round(-Double
4.54 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
35.34 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
2381.73 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
6402.7 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
7024.72 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
2710.57)))))
    green :: Pixel8
green = Integer -> Pixel8
trunc (Integer -> Pixel8) -> Integer -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round(Double
32.49 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
170.73 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
52.82 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
131.46 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
176.58 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
67.37)))))
    blue :: Pixel8
blue  = Integer -> Pixel8
trunc (Integer -> Pixel8) -> Integer -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round(Double
81.24 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
442.36 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
2482.43 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
6167.24 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
6614.94 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
2475.67)))))
    trunc :: Integer -> Pixel8
    trunc :: Integer -> Pixel8
trunc = Integer -> Pixel8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Pixel8) -> (Integer -> Integer) -> Integer -> Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
min Integer
255 (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
max Integer
0

-- | Jet colormap. Used to be the default in matlab. Obsolete.
--
--   <<docs/gifs/doc_jet.gif>>
jet :: Double -> PixelRGB8
jet :: Double -> PixelRGB8
jet Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 Pixel8
red Pixel8
green Pixel8
blue
  where
    red :: Pixel8
red   = Double -> Pixel8
trunc (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall a. Ord a => a -> a -> a
min (Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
1.5) (-Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
4.5)
    green :: Pixel8
green = Double -> Pixel8
trunc (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall a. Ord a => a -> a -> a
min (Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
0.5) (-Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
3.5)
    blue :: Pixel8
blue  = Double -> Pixel8
trunc (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall a. Ord a => a -> a -> a
min (Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
0.5) (-Double
4Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
2.5)
    trunc :: Double -> Pixel8
    trunc :: Double -> Pixel8
trunc = Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> (Double -> Double) -> Double -> Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Double -> Double
forall a. Ord a => a -> a -> a
min Double
255 (Double -> Double) -> (Double -> Double) -> Double -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Double -> Double
forall a. Ord a => a -> a -> a
max Double
0 (Double -> Double) -> (Double -> Double) -> Double -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Double -> Double
forall a. Num a => a -> a -> a
(*) Double
255

-- | hsv colormap. Goes from 0 degrees to 360 degrees.
--
--   <<docs/gifs/doc_hsv.gif>>
hsv :: Double -> PixelRGB8
hsv :: Double -> PixelRGB8
hsv Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
rDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255) (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
gDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255) (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
bDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255)
  where
    RGB Double
r Double
g Double
b = Double -> Double -> Double -> RGB Double
forall a. (RealFrac a, Ord a) => a -> a -> a -> RGB a
HSV.hsv (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
360) Double
1 Double
1

-- | Matlab hsv colormap. Goes from 0 degrees to 330 degrees.
--
--   <<docs/gifs/doc_hsvMatlab.gif>>
hsvMatlab :: Double -> PixelRGB8
hsvMatlab :: Double -> PixelRGB8
hsvMatlab Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
rDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255) (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
gDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255) (Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
bDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
255)
  where
    RGB Double
r Double
g Double
b = Double -> Double -> Double -> RGB Double
forall a. (RealFrac a, Ord a) => a -> a -> a -> RGB a
HSV.hsv (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
330) Double
1 Double
1

-- | Greyscale colormap.
--
--   <<docs/gifs/doc_greyscale.gif>>
greyscale :: Double -> PixelRGB8
greyscale :: Double -> PixelRGB8
greyscale Double
t = Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 Pixel8
v Pixel8
v Pixel8
v
  where
    v :: Pixel8
v = Double -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Pixel8) -> Double -> Pixel8
forall a b. (a -> b) -> a -> b
$ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
255

-- | Parula is the default colormap for matlab.
--
--   <<docs/gifs/doc_parula.gif>>
parula :: Double -> PixelRGB8
parula :: Double -> PixelRGB8
parula = Vector PixelRGB8 -> Double -> PixelRGB8
ramp Vector PixelRGB8
vec
  where
    vec :: Vector PixelRGB8
vec = [PixelRGB8] -> Vector PixelRGB8
forall a. [a] -> Vector a
V.fromList ([PixelRGB8] -> Vector PixelRGB8)
-> [PixelRGB8] -> Vector PixelRGB8
forall a b. (a -> b) -> a -> b
$ [Double] -> [PixelRGB8]
forall a. RealFrac a => [a] -> [PixelRGB8]
pixels [Double]
colorList
    pixels :: [a] -> [PixelRGB8]
pixels [] = []
    pixels (a
r:a
g:a
b:[a]
xs) =
      Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 (a -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (a -> Pixel8) -> a -> Pixel8
forall a b. (a -> b) -> a -> b
$ a
ra -> a -> a
forall a. Num a => a -> a -> a
*a
255) (a -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (a -> Pixel8) -> a -> Pixel8
forall a b. (a -> b) -> a -> b
$ a
ga -> a -> a
forall a. Num a => a -> a -> a
*a
255) (a -> Pixel8
forall a b. (RealFrac a, Integral b) => a -> b
round (a -> Pixel8) -> a -> Pixel8
forall a b. (a -> b) -> a -> b
$ a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
255) PixelRGB8 -> [PixelRGB8] -> [PixelRGB8]
forall a. a -> [a] -> [a]
:
      [a] -> [PixelRGB8]
pixels [a]
xs
    pixels [a]
_ = [Char] -> [PixelRGB8]
forall a. HasCallStack => [Char] -> a
error [Char]
"Reanimate.ColorMap.parula: Broken data"
    colorList :: [Double]
    colorList :: [Double]
colorList =
       [Double
0.2081, Double
0.1663, Double
0.5292
       ,Double
0.2091, Double
0.1721, Double
0.5411
       ,Double
0.2101, Double
0.1779, Double
0.5530
       ,Double
0.2109, Double
0.1837, Double
0.5650
       ,Double
0.2116, Double
0.1895, Double
0.5771
       ,Double
0.2121, Double
0.1954, Double
0.5892
       ,Double
0.2124, Double
0.2013, Double
0.6013
       ,Double
0.2125, Double
0.2072, Double
0.6135
       ,Double
0.2123, Double
0.2132, Double
0.6258
       ,Double
0.2118, Double
0.2192, Double
0.6381
       ,Double
0.2111, Double
0.2253, Double
0.6505
       ,Double
0.2099, Double
0.2315, Double
0.6629
       ,Double
0.2084, Double
0.2377, Double
0.6753
       ,Double
0.2063, Double
0.2440, Double
0.6878
       ,Double
0.2038, Double
0.2503, Double
0.7003
       ,Double
0.2006, Double
0.2568, Double
0.7129
       ,Double
0.1968, Double
0.2632, Double
0.7255
       ,Double
0.1921, Double
0.2698, Double
0.7381
       ,Double
0.1867, Double
0.2764, Double
0.7507
       ,Double
0.1802, Double
0.2832, Double
0.7634
       ,Double
0.1728, Double
0.2902, Double
0.7762
       ,Double
0.1641, Double
0.2975, Double
0.7890
       ,Double
0.1541, Double
0.3052, Double
0.8017
       ,Double
0.1427, Double
0.3132, Double
0.8145
       ,Double
0.1295, Double
0.3217, Double
0.8269
       ,Double
0.1147, Double
0.3306, Double
0.8387
       ,Double
0.0986, Double
0.3397, Double
0.8495
       ,Double
0.0816, Double
0.3486, Double
0.8588
       ,Double
0.0646, Double
0.3572, Double
0.8664
       ,Double
0.0482, Double
0.3651, Double
0.8722
       ,Double
0.0329, Double
0.3724, Double
0.8765
       ,Double
0.0213, Double
0.3792, Double
0.8796
       ,Double
0.0136, Double
0.3853, Double
0.8815
       ,Double
0.0086, Double
0.3911, Double
0.8827
       ,Double
0.0060, Double
0.3965, Double
0.8833
       ,Double
0.0051, Double
0.4017, Double
0.8834
       ,Double
0.0054, Double
0.4066, Double
0.8831
       ,Double
0.0067, Double
0.4113, Double
0.8825
       ,Double
0.0089, Double
0.4159, Double
0.8816
       ,Double
0.0116, Double
0.4203, Double
0.8805
       ,Double
0.0148, Double
0.4246, Double
0.8793
       ,Double
0.0184, Double
0.4288, Double
0.8779
       ,Double
0.0223, Double
0.4329, Double
0.8763
       ,Double
0.0264, Double
0.4370, Double
0.8747
       ,Double
0.0306, Double
0.4410, Double
0.8729
       ,Double
0.0349, Double
0.4449, Double
0.8711
       ,Double
0.0394, Double
0.4488, Double
0.8692
       ,Double
0.0437, Double
0.4526, Double
0.8672
       ,Double
0.0477, Double
0.4564, Double
0.8652
       ,Double
0.0514, Double
0.4602, Double
0.8632
       ,Double
0.0549, Double
0.4640, Double
0.8611
       ,Double
0.0582, Double
0.4677, Double
0.8589
       ,Double
0.0612, Double
0.4714, Double
0.8568
       ,Double
0.0640, Double
0.4751, Double
0.8546
       ,Double
0.0666, Double
0.4788, Double
0.8525
       ,Double
0.0689, Double
0.4825, Double
0.8503
       ,Double
0.0710, Double
0.4862, Double
0.8481
       ,Double
0.0729, Double
0.4899, Double
0.8460
       ,Double
0.0746, Double
0.4937, Double
0.8439
       ,Double
0.0761, Double
0.4974, Double
0.8418
       ,Double
0.0773, Double
0.5012, Double
0.8398
       ,Double
0.0782, Double
0.5051, Double
0.8378
       ,Double
0.0789, Double
0.5089, Double
0.8359
       ,Double
0.0794, Double
0.5129, Double
0.8341
       ,Double
0.0795, Double
0.5169, Double
0.8324
       ,Double
0.0793, Double
0.5210, Double
0.8308
       ,Double
0.0788, Double
0.5251, Double
0.8293
       ,Double
0.0778, Double
0.5295, Double
0.8280
       ,Double
0.0764, Double
0.5339, Double
0.8270
       ,Double
0.0746, Double
0.5384, Double
0.8261
       ,Double
0.0724, Double
0.5431, Double
0.8253
       ,Double
0.0698, Double
0.5479, Double
0.8247
       ,Double
0.0668, Double
0.5527, Double
0.8243
       ,Double
0.0636, Double
0.5577, Double
0.8239
       ,Double
0.0600, Double
0.5627, Double
0.8237
       ,Double
0.0562, Double
0.5677, Double
0.8234
       ,Double
0.0523, Double
0.5727, Double
0.8231
       ,Double
0.0484, Double
0.5777, Double
0.8228
       ,Double
0.0445, Double
0.5826, Double
0.8223
       ,Double
0.0408, Double
0.5874, Double
0.8217
       ,Double
0.0372, Double
0.5922, Double
0.8209
       ,Double
0.0342, Double
0.5968, Double
0.8198
       ,Double
0.0317, Double
0.6012, Double
0.8186
       ,Double
0.0296, Double
0.6055, Double
0.8171
       ,Double
0.0279, Double
0.6097, Double
0.8154
       ,Double
0.0265, Double
0.6137, Double
0.8135
       ,Double
0.0255, Double
0.6176, Double
0.8114
       ,Double
0.0248, Double
0.6214, Double
0.8091
       ,Double
0.0243, Double
0.6250, Double
0.8066
       ,Double
0.0239, Double
0.6285, Double
0.8039
       ,Double
0.0237, Double
0.6319, Double
0.8010
       ,Double
0.0235, Double
0.6352, Double
0.7980
       ,Double
0.0233, Double
0.6384, Double
0.7948
       ,Double
0.0231, Double
0.6415, Double
0.7916
       ,Double
0.0230, Double
0.6445, Double
0.7881
       ,Double
0.0229, Double
0.6474, Double
0.7846
       ,Double
0.0227, Double
0.6503, Double
0.7810
       ,Double
0.0227, Double
0.6531, Double
0.7773
       ,Double
0.0232, Double
0.6558, Double
0.7735
       ,Double
0.0238, Double
0.6585, Double
0.7696
       ,Double
0.0246, Double
0.6611, Double
0.7656
       ,Double
0.0263, Double
0.6637, Double
0.7615
       ,Double
0.0282, Double
0.6663, Double
0.7574
       ,Double
0.0306, Double
0.6688, Double
0.7532
       ,Double
0.0338, Double
0.6712, Double
0.7490
       ,Double
0.0373, Double
0.6737, Double
0.7446
       ,Double
0.0418, Double
0.6761, Double
0.7402
       ,Double
0.0467, Double
0.6784, Double
0.7358
       ,Double
0.0516, Double
0.6808, Double
0.7313
       ,Double
0.0574, Double
0.6831, Double
0.7267
       ,Double
0.0629, Double
0.6854, Double
0.7221
       ,Double
0.0692, Double
0.6877, Double
0.7173
       ,Double
0.0755, Double
0.6899, Double
0.7126
       ,Double
0.0820, Double
0.6921, Double
0.7078
       ,Double
0.0889, Double
0.6943, Double
0.7029
       ,Double
0.0956, Double
0.6965, Double
0.6979
       ,Double
0.1031, Double
0.6986, Double
0.6929
       ,Double
0.1104, Double
0.7007, Double
0.6878
       ,Double
0.1180, Double
0.7028, Double
0.6827
       ,Double
0.1258, Double
0.7049, Double
0.6775
       ,Double
0.1335, Double
0.7069, Double
0.6723
       ,Double
0.1418, Double
0.7089, Double
0.6669
       ,Double
0.1499, Double
0.7109, Double
0.6616
       ,Double
0.1585, Double
0.7129, Double
0.6561
       ,Double
0.1671, Double
0.7148, Double
0.6507
       ,Double
0.1758, Double
0.7168, Double
0.6451
       ,Double
0.1849, Double
0.7186, Double
0.6395
       ,Double
0.1938, Double
0.7205, Double
0.6338
       ,Double
0.2033, Double
0.7223, Double
0.6281
       ,Double
0.2128, Double
0.7241, Double
0.6223
       ,Double
0.2224, Double
0.7259, Double
0.6165
       ,Double
0.2324, Double
0.7275, Double
0.6107
       ,Double
0.2423, Double
0.7292, Double
0.6048
       ,Double
0.2527, Double
0.7308, Double
0.5988
       ,Double
0.2631, Double
0.7324, Double
0.5929
       ,Double
0.2735, Double
0.7339, Double
0.5869
       ,Double
0.2845, Double
0.7354, Double
0.5809
       ,Double
0.2953, Double
0.7368, Double
0.5749
       ,Double
0.3064, Double
0.7381, Double
0.5689
       ,Double
0.3177, Double
0.7394, Double
0.5630
       ,Double
0.3289, Double
0.7406, Double
0.5570
       ,Double
0.3405, Double
0.7417, Double
0.5512
       ,Double
0.3520, Double
0.7428, Double
0.5453
       ,Double
0.3635, Double
0.7438, Double
0.5396
       ,Double
0.3753, Double
0.7446, Double
0.5339
       ,Double
0.3869, Double
0.7454, Double
0.5283
       ,Double
0.3986, Double
0.7461, Double
0.5229
       ,Double
0.4103, Double
0.7467, Double
0.5175
       ,Double
0.4218, Double
0.7473, Double
0.5123
       ,Double
0.4334, Double
0.7477, Double
0.5072
       ,Double
0.4447, Double
0.7482, Double
0.5021
       ,Double
0.4561, Double
0.7485, Double
0.4972
       ,Double
0.4672, Double
0.7487, Double
0.4924
       ,Double
0.4783, Double
0.7489, Double
0.4877
       ,Double
0.4892, Double
0.7491, Double
0.4831
       ,Double
0.5000, Double
0.7491, Double
0.4786
       ,Double
0.5106, Double
0.7492, Double
0.4741
       ,Double
0.5212, Double
0.7492, Double
0.4698
       ,Double
0.5315, Double
0.7491, Double
0.4655
       ,Double
0.5418, Double
0.7490, Double
0.4613
       ,Double
0.5519, Double
0.7489, Double
0.4571
       ,Double
0.5619, Double
0.7487, Double
0.4531
       ,Double
0.5718, Double
0.7485, Double
0.4490
       ,Double
0.5816, Double
0.7482, Double
0.4451
       ,Double
0.5913, Double
0.7479, Double
0.4412
       ,Double
0.6009, Double
0.7476, Double
0.4374
       ,Double
0.6103, Double
0.7473, Double
0.4335
       ,Double
0.6197, Double
0.7469, Double
0.4298
       ,Double
0.6290, Double
0.7465, Double
0.4261
       ,Double
0.6382, Double
0.7460, Double
0.4224
       ,Double
0.6473, Double
0.7456, Double
0.4188
       ,Double
0.6564, Double
0.7451, Double
0.4152
       ,Double
0.6653, Double
0.7446, Double
0.4116
       ,Double
0.6742, Double
0.7441, Double
0.4081
       ,Double
0.6830, Double
0.7435, Double
0.4046
       ,Double
0.6918, Double
0.7430, Double
0.4011
       ,Double
0.7004, Double
0.7424, Double
0.3976
       ,Double
0.7091, Double
0.7418, Double
0.3942
       ,Double
0.7176, Double
0.7412, Double
0.3908
       ,Double
0.7261, Double
0.7405, Double
0.3874
       ,Double
0.7346, Double
0.7399, Double
0.3840
       ,Double
0.7430, Double
0.7392, Double
0.3806
       ,Double
0.7513, Double
0.7385, Double
0.3773
       ,Double
0.7596, Double
0.7378, Double
0.3739
       ,Double
0.7679, Double
0.7372, Double
0.3706
       ,Double
0.7761, Double
0.7364, Double
0.3673
       ,Double
0.7843, Double
0.7357, Double
0.3639
       ,Double
0.7924, Double
0.7350, Double
0.3606
       ,Double
0.8005, Double
0.7343, Double
0.3573
       ,Double
0.8085, Double
0.7336, Double
0.3539
       ,Double
0.8166, Double
0.7329, Double
0.3506
       ,Double
0.8246, Double
0.7322, Double
0.3472
       ,Double
0.8325, Double
0.7315, Double
0.3438
       ,Double
0.8405, Double
0.7308, Double
0.3404
       ,Double
0.8484, Double
0.7301, Double
0.3370
       ,Double
0.8563, Double
0.7294, Double
0.3336
       ,Double
0.8642, Double
0.7288, Double
0.3300
       ,Double
0.8720, Double
0.7282, Double
0.3265
       ,Double
0.8798, Double
0.7276, Double
0.3229
       ,Double
0.8877, Double
0.7271, Double
0.3193
       ,Double
0.8954, Double
0.7266, Double
0.3156
       ,Double
0.9032, Double
0.7262, Double
0.3117
       ,Double
0.9110, Double
0.7259, Double
0.3078
       ,Double
0.9187, Double
0.7256, Double
0.3038
       ,Double
0.9264, Double
0.7256, Double
0.2996
       ,Double
0.9341, Double
0.7256, Double
0.2953
       ,Double
0.9417, Double
0.7259, Double
0.2907
       ,Double
0.9493, Double
0.7264, Double
0.2859
       ,Double
0.9567, Double
0.7273, Double
0.2808
       ,Double
0.9639, Double
0.7285, Double
0.2754
       ,Double
0.9708, Double
0.7303, Double
0.2696
       ,Double
0.9773, Double
0.7326, Double
0.2634
       ,Double
0.9831, Double
0.7355, Double
0.2570
       ,Double
0.9882, Double
0.7390, Double
0.2504
       ,Double
0.9922, Double
0.7431, Double
0.2437
       ,Double
0.9952, Double
0.7476, Double
0.2373
       ,Double
0.9973, Double
0.7524, Double
0.2310
       ,Double
0.9986, Double
0.7573, Double
0.2251
       ,Double
0.9991, Double
0.7624, Double
0.2195
       ,Double
0.9990, Double
0.7675, Double
0.2141
       ,Double
0.9985, Double
0.7726, Double
0.2090
       ,Double
0.9976, Double
0.7778, Double
0.2042
       ,Double
0.9964, Double
0.7829, Double
0.1995
       ,Double
0.9950, Double
0.7880, Double
0.1949
       ,Double
0.9933, Double
0.7931, Double
0.1905
       ,Double
0.9914, Double
0.7981, Double
0.1863
       ,Double
0.9894, Double
0.8032, Double
0.1821
       ,Double
0.9873, Double
0.8083, Double
0.1780
       ,Double
0.9851, Double
0.8133, Double
0.1740
       ,Double
0.9828, Double
0.8184, Double
0.1700
       ,Double
0.9805, Double
0.8235, Double
0.1661
       ,Double
0.9782, Double
0.8286, Double
0.1622
       ,Double
0.9759, Double
0.8337, Double
0.1583
       ,Double
0.9736, Double
0.8389, Double
0.1544
       ,Double
0.9713, Double
0.8441, Double
0.1505
       ,Double
0.9692, Double
0.8494, Double
0.1465
       ,Double
0.9672, Double
0.8548, Double
0.1425
       ,Double
0.9654, Double
0.8603, Double
0.1385
       ,Double
0.9638, Double
0.8659, Double
0.1343
       ,Double
0.9623, Double
0.8716, Double
0.1301
       ,Double
0.9611, Double
0.8774, Double
0.1258
       ,Double
0.9600, Double
0.8834, Double
0.1215
       ,Double
0.9593, Double
0.8895, Double
0.1171
       ,Double
0.9588, Double
0.8958, Double
0.1126
       ,Double
0.9586, Double
0.9022, Double
0.1082
       ,Double
0.9587, Double
0.9088, Double
0.1036
       ,Double
0.9591, Double
0.9155, Double
0.0990
       ,Double
0.9599, Double
0.9225, Double
0.0944
       ,Double
0.9610, Double
0.9296, Double
0.0897
       ,Double
0.9624, Double
0.9368, Double
0.0850
       ,Double
0.9641, Double
0.9443, Double
0.0802
       ,Double
0.9662, Double
0.9518, Double
0.0753
       ,Double
0.9685, Double
0.9595, Double
0.0703
       ,Double
0.9710, Double
0.9673, Double
0.0651
       ,Double
0.9736, Double
0.9752, Double
0.0597
       ,Double
0.9763, Double
0.9831, Double
0.0538]

--------------------------------------------------------------------------------
-- Helpers

colors :: Text -> Vector PixelRGB8
colors :: Text -> Vector PixelRGB8
colors = [PixelRGB8] -> Vector PixelRGB8
forall a. [a] -> Vector a
V.fromList ([PixelRGB8] -> Vector PixelRGB8)
-> (Text -> [PixelRGB8]) -> Text -> Vector PixelRGB8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> PixelRGB8) -> [Text] -> [PixelRGB8]
forall a b. (a -> b) -> [a] -> [b]
map ([Pixel8] -> PixelRGB8
toColor ([Pixel8] -> PixelRGB8) -> (Text -> [Pixel8]) -> Text -> PixelRGB8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Pixel8) -> [Char] -> [Pixel8]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Pixel8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Pixel8) -> (Char -> Int) -> Char -> Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
digitToInt) ([Char] -> [Pixel8]) -> (Text -> [Char]) -> Text -> [Pixel8]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Char]
T.unpack) ([Text] -> [PixelRGB8]) -> (Text -> [Text]) -> Text -> [PixelRGB8]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text -> [Text]
T.chunksOf Int
6
  where
    toColor :: [Pixel8] -> PixelRGB8
toColor [Pixel8
r1,Pixel8
r2,Pixel8
g1,Pixel8
g2,Pixel8
b1,Pixel8
b2] =
      Pixel8 -> Pixel8 -> Pixel8 -> PixelRGB8
PixelRGB8 (Pixel8
r1 Pixel8 -> Int -> Pixel8
forall a. Bits a => a -> Int -> a
`shiftL` Int
4 Pixel8 -> Pixel8 -> Pixel8
forall a. Num a => a -> a -> a
+ Pixel8
r2) (Pixel8
g1 Pixel8 -> Int -> Pixel8
forall a. Bits a => a -> Int -> a
`shiftL` Int
4 Pixel8 -> Pixel8 -> Pixel8
forall a. Num a => a -> a -> a
+ Pixel8
g2) (Pixel8
b1 Pixel8 -> Int -> Pixel8
forall a. Bits a => a -> Int -> a
`shiftL` Int
4Pixel8 -> Pixel8 -> Pixel8
forall a. Num a => a -> a -> a
+Pixel8
b2)
    toColor [Pixel8]
_ = [Char] -> PixelRGB8
forall a. HasCallStack => [Char] -> a
error [Char]
"Reanimate.ColorMap.colors: Broken data"

ramp :: Vector PixelRGB8 -> Double -> PixelRGB8
ramp :: Vector PixelRGB8 -> Double -> PixelRGB8
ramp Vector PixelRGB8
v = \Double
t -> Vector PixelRGB8
v Vector PixelRGB8 -> Int -> PixelRGB8
forall a. Vector a -> Int -> a
V.! Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 (Int -> Int -> Int
forall a. Ord a => a -> a -> a
min (Int
lenInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ Double -> Int
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> Double -> Int
forall a b. (a -> b) -> a -> b
$ Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
len'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
1))
  where
    len :: Int
len = Vector PixelRGB8 -> Int
forall a. Vector a -> Int
V.length Vector PixelRGB8
v
    len' :: Double
len' = Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len