mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-14 01:22:20 +00:00
Depend on reanimate-svg >= 0.13
This commit is contained in:
parent
7d16bc79b0
commit
e9a2bd3bd0
9 changed files with 54 additions and 35 deletions
13
examples/doc_simpleIcon.hs
Executable file
13
examples/doc_simpleIcon.hs
Executable 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 ]
|
||||
|
|
@ -134,7 +134,7 @@ library
|
|||
process >=1.6.3.0,
|
||||
random >=1.1,
|
||||
random-shuffle >=0.0.4,
|
||||
reanimate-svg >=0.12.2.0,
|
||||
reanimate-svg >=0.13.0.0,
|
||||
split >=0.2.3.3,
|
||||
temporary >=1.3,
|
||||
text >=1.2.3.0,
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
{-|
|
||||
Module : Reanimate.Builtin.Images
|
||||
Copyright : Written by David Himmelstrup
|
||||
License : Unlicense
|
||||
Maintainer : lemmih@gmail.com
|
||||
Stability : experimental
|
||||
Portability : POSIX
|
||||
|
||||
Collection of built-in images.
|
||||
|
||||
-}
|
||||
-- |
|
||||
-- Module : Reanimate.Builtin.Images
|
||||
-- Copyright : Written by David Himmelstrup
|
||||
-- License : Unlicense
|
||||
-- Maintainer : lemmih@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : POSIX
|
||||
--
|
||||
-- Collection of built-in images.
|
||||
module Reanimate.Builtin.Images
|
||||
( svgLogo
|
||||
, haskellLogo
|
||||
, githubIcon
|
||||
, githubWhiteIcon
|
||||
, smallEarth
|
||||
) where
|
||||
( svgLogo,
|
||||
haskellLogo,
|
||||
githubIcon,
|
||||
githubWhiteIcon,
|
||||
smallEarth,
|
||||
)
|
||||
where
|
||||
|
||||
import Codec.Picture
|
||||
import qualified Data.ByteString as B
|
||||
import Graphics.SvgTree (parseSvgFile)
|
||||
import Paths_reanimate
|
||||
import Reanimate.Animation
|
||||
import Reanimate.Svg
|
||||
import System.IO.Unsafe
|
||||
import Codec.Picture
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.Text.IO as T
|
||||
import Graphics.SvgTree (parseSvgFile)
|
||||
import Paths_reanimate
|
||||
import Reanimate.Animation
|
||||
import Reanimate.Svg
|
||||
import System.IO.Unsafe
|
||||
|
||||
embedImage :: FilePath -> IO SVG
|
||||
embedImage key = do
|
||||
svg_file <- getDataFileName key
|
||||
svg_data <- B.readFile svg_file
|
||||
svg_data <- T.readFile svg_file
|
||||
case parseSvgFile svg_file svg_data of
|
||||
Nothing -> error "Malformed svg"
|
||||
Nothing -> error "Malformed svg"
|
||||
Just svg -> return $ embedDocument svg
|
||||
|
||||
loadJPG :: FilePath -> Image PixelRGBA8
|
||||
|
|
@ -38,25 +38,29 @@ loadJPG key = unsafePerformIO $ do
|
|||
jpg_file <- getDataFileName key
|
||||
dat <- B.readFile jpg_file
|
||||
case decodeJpeg dat of
|
||||
Left err -> error err
|
||||
Left err -> error err
|
||||
Right img -> return $ convertRGBA8 img
|
||||
|
||||
{- HLINT ignore svgLogo -}
|
||||
|
||||
-- | <<docs/gifs/doc_svgLogo.gif>>
|
||||
svgLogo :: SVG
|
||||
svgLogo = unsafePerformIO $ embedImage "data/svg-logo.svg"
|
||||
|
||||
{- HLINT ignore haskellLogo -}
|
||||
|
||||
-- | <<docs/gifs/doc_haskellLogo.gif>>
|
||||
haskellLogo :: SVG
|
||||
haskellLogo = unsafePerformIO $ embedImage "data/haskell.svg"
|
||||
|
||||
{- HLINT ignore githubIcon -}
|
||||
|
||||
-- | <<docs/gifs/doc_githubIcon.gif>>
|
||||
githubIcon :: SVG
|
||||
githubIcon = unsafePerformIO $ embedImage "data/github-icon.svg"
|
||||
|
||||
{-# NOINLINE githubWhiteIcon #-}
|
||||
|
||||
-- | <<docs/gifs/doc_githubWhiteIcon.gif>>
|
||||
githubWhiteIcon :: SVG
|
||||
githubWhiteIcon = unsafePerformIO $ embedImage "data/github-icon-white.svg"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import Data.Hashable
|
|||
import Data.Monoid
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import GHC.Generics (Generic)
|
||||
import Graphics.SvgTree
|
||||
|
|
@ -227,7 +228,7 @@ latexToSVG engine dviExt latexExec latexArgs tex = do
|
|||
"-o",
|
||||
svg_file
|
||||
]
|
||||
svg_data <- B.readFile svg_file
|
||||
svg_data <- T.readFile svg_file
|
||||
case parseSvgFile svg_file svg_data of
|
||||
Nothing -> error "Malformed svg"
|
||||
Just svg ->
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import qualified Data.ByteString.Base64.Lazy as Base64
|
|||
import qualified Data.ByteString.Lazy.Char8 as LBS
|
||||
import Data.Hashable
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.IO as T
|
||||
import Graphics.SvgTree ( Number(..)
|
||||
, defaultSvg
|
||||
, parseSvgFile
|
||||
|
|
@ -81,7 +82,7 @@ mkImage
|
|||
-> FilePath -- ^ Path to external image file.
|
||||
-> SVG
|
||||
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
|
||||
Nothing -> error "Malformed svg"
|
||||
Just svg ->
|
||||
|
|
@ -273,7 +274,7 @@ vectorize_ args path = unsafePerformIO $ do
|
|||
runCmd magick [path, "-flatten", tmpBmpPath]
|
||||
runCmd potrace (args ++ ["--svg", "--output", tmpSvgPath, tmpBmpPath])
|
||||
renameOrCopyFile tmpSvgPath svgPath
|
||||
svg_data <- B.readFile svgPath
|
||||
svg_data <- T.readFile svgPath
|
||||
case parseSvgFile svgPath svg_data of
|
||||
Nothing -> do
|
||||
removeFile svgPath
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ packages:
|
|||
- .
|
||||
|
||||
extra-deps:
|
||||
- reanimate-svg-0.12.2.0
|
||||
- reanimate-svg-0.13.0.0
|
||||
- chiphunk-0.1.2.1
|
||||
- cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3
|
||||
- fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ packages:
|
|||
- .
|
||||
|
||||
extra-deps:
|
||||
- reanimate-svg-0.12.2.0
|
||||
- reanimate-svg-0.13.0.0
|
||||
- chiphunk-0.1.2.1
|
||||
- cubicbezier-0.6.0.6@sha256:2191ff47144d9a13a2784651a33d340cd31be1926a6c188925143103eb3c8db3
|
||||
- fast-math-1.0.2@sha256:91181eb836e54413cc5a841e797c42b2264954e893ea530b6fc4da0dccf6a8b7
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ packages:
|
|||
extra-deps:
|
||||
- chiphunk-0.1.2.1
|
||||
- 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-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286
|
||||
- vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ packages:
|
|||
|
||||
extra-deps:
|
||||
- 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-combinatorial-0.11.0.0@sha256:03176f235a1c49a415fe1266274dafca84deb917cbcbf9a654452686b4cd2bfe,8286
|
||||
- vinyl-0.13.0@sha256:0f247cd3f8682b30881a07de18e6fec52d540646fbcb328420049cc8d63cd407,3724
|
||||
|
|
|
|||
Loading…
Reference in a new issue