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