Depend on reanimate-svg >= 0.13

This commit is contained in:
David Himmelstrup 2020-10-10 15:19:55 +08:00
commit e9a2bd3bd0
9 changed files with 54 additions and 35 deletions

13
examples/doc_simpleIcon.hs Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env stack
-- stack runghc --package reanimate
module Main(main) where
import Reanimate
import Reanimate.External
import Codec.Picture.Types
main :: IO ()
main = reanimate $ staticFrame 1 $
let icon = "cplusplus" in mkGroup
[ mkBackgroundPixel (promotePixel $ simpleIconColor icon)
, withFillOpacity 1 $ simpleIcon icon ]

View file

@ -134,7 +134,7 @@ library
process >=1.6.3.0, process >=1.6.3.0,
random >=1.1, random >=1.1,
random-shuffle >=0.0.4, random-shuffle >=0.0.4,
reanimate-svg >=0.12.2.0, reanimate-svg >=0.13.0.0,
split >=0.2.3.3, split >=0.2.3.3,
temporary >=1.3, temporary >=1.3,
text >=1.2.3.0, text >=1.2.3.0,

View file

@ -1,24 +1,24 @@
{-| -- |
Module : Reanimate.Builtin.Images -- Module : Reanimate.Builtin.Images
Copyright : Written by David Himmelstrup -- Copyright : Written by David Himmelstrup
License : Unlicense -- License : Unlicense
Maintainer : lemmih@gmail.com -- Maintainer : lemmih@gmail.com
Stability : experimental -- Stability : experimental
Portability : POSIX -- Portability : POSIX
--
Collection of built-in images. -- Collection of built-in images.
-}
module Reanimate.Builtin.Images module Reanimate.Builtin.Images
( svgLogo ( svgLogo,
, haskellLogo haskellLogo,
, githubIcon githubIcon,
, githubWhiteIcon githubWhiteIcon,
, smallEarth smallEarth,
) where )
where
import Codec.Picture import Codec.Picture
import qualified Data.ByteString as B import qualified Data.ByteString as B
import qualified Data.Text.IO as T
import Graphics.SvgTree (parseSvgFile) import Graphics.SvgTree (parseSvgFile)
import Paths_reanimate import Paths_reanimate
import Reanimate.Animation import Reanimate.Animation
@ -28,7 +28,7 @@ import System.IO.Unsafe
embedImage :: FilePath -> IO SVG embedImage :: FilePath -> IO SVG
embedImage key = do embedImage key = do
svg_file <- getDataFileName key svg_file <- getDataFileName key
svg_data <- B.readFile svg_file svg_data <- T.readFile svg_file
case parseSvgFile svg_file svg_data of case parseSvgFile svg_file svg_data of
Nothing -> error "Malformed svg" Nothing -> error "Malformed svg"
Just svg -> return $ embedDocument svg Just svg -> return $ embedDocument svg
@ -42,21 +42,25 @@ loadJPG key = unsafePerformIO $ do
Right img -> return $ convertRGBA8 img Right img -> return $ convertRGBA8 img
{- HLINT ignore svgLogo -} {- HLINT ignore svgLogo -}
-- | <<docs/gifs/doc_svgLogo.gif>> -- | <<docs/gifs/doc_svgLogo.gif>>
svgLogo :: SVG svgLogo :: SVG
svgLogo = unsafePerformIO $ embedImage "data/svg-logo.svg" svgLogo = unsafePerformIO $ embedImage "data/svg-logo.svg"
{- HLINT ignore haskellLogo -} {- HLINT ignore haskellLogo -}
-- | <<docs/gifs/doc_haskellLogo.gif>> -- | <<docs/gifs/doc_haskellLogo.gif>>
haskellLogo :: SVG haskellLogo :: SVG
haskellLogo = unsafePerformIO $ embedImage "data/haskell.svg" haskellLogo = unsafePerformIO $ embedImage "data/haskell.svg"
{- HLINT ignore githubIcon -} {- HLINT ignore githubIcon -}
-- | <<docs/gifs/doc_githubIcon.gif>> -- | <<docs/gifs/doc_githubIcon.gif>>
githubIcon :: SVG githubIcon :: SVG
githubIcon = unsafePerformIO $ embedImage "data/github-icon.svg" githubIcon = unsafePerformIO $ embedImage "data/github-icon.svg"
{-# NOINLINE githubWhiteIcon #-} {-# NOINLINE githubWhiteIcon #-}
-- | <<docs/gifs/doc_githubWhiteIcon.gif>> -- | <<docs/gifs/doc_githubWhiteIcon.gif>>
githubWhiteIcon :: SVG githubWhiteIcon :: SVG
githubWhiteIcon = unsafePerformIO $ embedImage "data/github-icon-white.svg" githubWhiteIcon = unsafePerformIO $ embedImage "data/github-icon-white.svg"

View file

@ -41,6 +41,7 @@ import Data.Hashable
import Data.Monoid import Data.Monoid
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as T import qualified Data.Text.Encoding as T
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Graphics.SvgTree import Graphics.SvgTree
@ -227,7 +228,7 @@ latexToSVG engine dviExt latexExec latexArgs tex = do
"-o", "-o",
svg_file svg_file
] ]
svg_data <- B.readFile svg_file svg_data <- T.readFile svg_file
case parseSvgFile svg_file svg_data of case parseSvgFile svg_file svg_data of
Nothing -> error "Malformed svg" Nothing -> error "Malformed svg"
Just svg -> Just svg ->

View file

@ -36,6 +36,7 @@ import qualified Data.ByteString.Base64.Lazy as Base64
import qualified Data.ByteString.Lazy.Char8 as LBS import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Hashable import Data.Hashable
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.IO as T
import Graphics.SvgTree ( Number(..) import Graphics.SvgTree ( Number(..)
, defaultSvg , defaultSvg
, parseSvgFile , parseSvgFile
@ -81,7 +82,7 @@ mkImage
-> FilePath -- ^ Path to external image file. -> FilePath -- ^ Path to external image file.
-> SVG -> SVG
mkImage width height path | takeExtension path == ".svg" = unsafePerformIO $ do mkImage width height path | takeExtension path == ".svg" = unsafePerformIO $ do
svg_data <- B.readFile path svg_data <- T.readFile path
case parseSvgFile path svg_data of case parseSvgFile path svg_data of
Nothing -> error "Malformed svg" Nothing -> error "Malformed svg"
Just svg -> Just svg ->
@ -273,7 +274,7 @@ vectorize_ args path = unsafePerformIO $ do
runCmd magick [path, "-flatten", tmpBmpPath] runCmd magick [path, "-flatten", tmpBmpPath]
runCmd potrace (args ++ ["--svg", "--output", tmpSvgPath, tmpBmpPath]) runCmd potrace (args ++ ["--svg", "--output", tmpSvgPath, tmpBmpPath])
renameOrCopyFile tmpSvgPath svgPath renameOrCopyFile tmpSvgPath svgPath
svg_data <- B.readFile svgPath svg_data <- T.readFile svgPath
case parseSvgFile svgPath svg_data of case parseSvgFile svgPath svg_data of
Nothing -> do Nothing -> do
removeFile svgPath removeFile svgPath

View file

@ -6,7 +6,7 @@ packages:
- . - .
extra-deps: extra-deps:
- reanimate-svg-0.12.2.0 - reanimate-svg-0.13.0.0
- chiphunk-0.1.2.1 - chiphunk-0.1.2.1
- cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3 - cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3
- fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7 - fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7

View file

@ -6,7 +6,7 @@ packages:
- . - .
extra-deps: extra-deps:
- reanimate-svg-0.12.2.0 - reanimate-svg-0.13.0.0
- chiphunk-0.1.2.1 - chiphunk-0.1.2.1
- cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3 - cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3
- fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7 - fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7

View file

@ -8,7 +8,7 @@ packages:
extra-deps: extra-deps:
- chiphunk-0.1.2.1 - chiphunk-0.1.2.1
- earcut-0.1.0.4@sha256:d5118b3eecf24d130263d81fb30f1ff56b1db43036582bfd1d8cc9ba3adae8be,1010 - earcut-0.1.0.4@sha256:d5118b3eecf24d130263d81fb30f1ff56b1db43036582bfd1d8cc9ba3adae8be,1010
- reanimate-svg-0.12.2.0 - reanimate-svg-0.13.0.0
- hgeometry-0.11.0.0@sha256:09ead201a6ac3492c0be8dda5a6b32792b9ae87cab730b8362d46ee8d5c2acb4,11714 - hgeometry-0.11.0.0@sha256:09ead201a6ac3492c0be8dda5a6b32792b9ae87cab730b8362d46ee8d5c2acb4,11714
- hgeometry-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286 - hgeometry-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286
- vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724 - vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724

View file

@ -7,7 +7,7 @@ packages:
extra-deps: extra-deps:
- earcut-0.1.0.4 - earcut-0.1.0.4
- reanimate-svg-0.12.2.0 - reanimate-svg-0.13.0.0
- hgeometry-0.11.0.0@sha256:09ead201a6ac3492c0be8dda5a6b32792b9ae87cab730b8362d46ee8d5c2acb4,11714 - hgeometry-0.11.0.0@sha256:09ead201a6ac3492c0be8dda5a6b32792b9ae87cab730b8362d46ee8d5c2acb4,11714
- hgeometry-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286 - hgeometry-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286
- vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724 - vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724