never executed always true always false
    1 {-|
    2 Module      : Reanimate.Builtin.Images
    3 Copyright   : Written by David Himmelstrup
    4 License     : Unlicense
    5 Maintainer  : lemmih@gmail.com
    6 Stability   : experimental
    7 Portability : POSIX
    8 
    9 Collection of built-in images.
   10 
   11 -}
   12 module Reanimate.Builtin.Images
   13   ( svgLogo
   14   , haskellLogo
   15   , githubIcon
   16   , githubWhiteIcon
   17   , smallEarth
   18   ) where
   19 
   20 import           Codec.Picture
   21 import qualified Data.ByteString     as B
   22 import           Graphics.SvgTree    (parseSvgFile)
   23 import           Paths_reanimate
   24 import           Reanimate.Animation
   25 import           Reanimate.Svg
   26 import           System.IO.Unsafe
   27 
   28 embedImage :: FilePath -> IO SVG
   29 embedImage key = do
   30   svg_file <- getDataFileName key
   31   svg_data <- B.readFile svg_file
   32   case parseSvgFile svg_file svg_data of
   33     Nothing  -> error "Malformed svg"
   34     Just svg -> return $ embedDocument svg
   35 
   36 loadJPG :: FilePath -> Image PixelRGBA8
   37 loadJPG key = unsafePerformIO $ do
   38   jpg_file <- getDataFileName key
   39   dat <- B.readFile jpg_file
   40   case decodeJpeg dat of
   41     Left err  -> error err
   42     Right img -> return $ convertRGBA8 img
   43 
   44 {- HLINT ignore svgLogo -}
   45 -- | <<docs/gifs/doc_svgLogo.gif>>
   46 svgLogo :: SVG
   47 svgLogo = unsafePerformIO $ embedImage "data/svg-logo.svg"
   48 
   49 {- HLINT ignore haskellLogo -}
   50 -- | <<docs/gifs/doc_haskellLogo.gif>>
   51 haskellLogo :: SVG
   52 haskellLogo = unsafePerformIO $ embedImage "data/haskell.svg"
   53 
   54 {- HLINT ignore githubIcon -}
   55 -- | <<docs/gifs/doc_githubIcon.gif>>
   56 githubIcon :: SVG
   57 githubIcon = unsafePerformIO $ embedImage "data/github-icon.svg"
   58 
   59 {-# NOINLINE githubWhiteIcon #-}
   60 -- | <<docs/gifs/doc_githubWhiteIcon.gif>>
   61 githubWhiteIcon :: SVG
   62 githubWhiteIcon = unsafePerformIO $ embedImage "data/github-icon-white.svg"
   63 
   64 -- | 300x150 equirectangular earth
   65 --
   66 --   <<docs/gifs/doc_smallEarth.gif>>
   67 smallEarth :: Image PixelRGBA8
   68 smallEarth = loadJPG "data/small_earth.jpg"