diff --git a/examples/doc_simpleIcon.hs b/examples/doc_simpleIcon.hs new file mode 100755 index 0000000..6f8bc54 --- /dev/null +++ b/examples/doc_simpleIcon.hs @@ -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 ] diff --git a/reanimate.cabal b/reanimate.cabal index ae0eeab..0ac331b 100644 --- a/reanimate.cabal +++ b/reanimate.cabal @@ -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, diff --git a/src/Reanimate/Builtin/Images.hs b/src/Reanimate/Builtin/Images.hs index d8fbe38..70c2f7b 100644 --- a/src/Reanimate/Builtin/Images.hs +++ b/src/Reanimate/Builtin/Images.hs @@ -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 -} + -- | <> svgLogo :: SVG svgLogo = unsafePerformIO $ embedImage "data/svg-logo.svg" {- HLINT ignore haskellLogo -} + -- | <> haskellLogo :: SVG haskellLogo = unsafePerformIO $ embedImage "data/haskell.svg" {- HLINT ignore githubIcon -} + -- | <> githubIcon :: SVG githubIcon = unsafePerformIO $ embedImage "data/github-icon.svg" {-# NOINLINE githubWhiteIcon #-} + -- | <> githubWhiteIcon :: SVG githubWhiteIcon = unsafePerformIO $ embedImage "data/github-icon-white.svg" diff --git a/src/Reanimate/LaTeX.hs b/src/Reanimate/LaTeX.hs index 4123ad5..e065c02 100644 --- a/src/Reanimate/LaTeX.hs +++ b/src/Reanimate/LaTeX.hs @@ -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 -> diff --git a/src/Reanimate/Raster.hs b/src/Reanimate/Raster.hs index 4a6eb0d..ca0a7e0 100644 --- a/src/Reanimate/Raster.hs +++ b/src/Reanimate/Raster.hs @@ -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 diff --git a/stack-lts-13.yaml b/stack-lts-13.yaml index 90307a9..695e158 100644 --- a/stack-lts-13.yaml +++ b/stack-lts-13.yaml @@ -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 diff --git a/stack-lts-14.yaml b/stack-lts-14.yaml index 76bbcfb..2b39b0a 100644 --- a/stack-lts-14.yaml +++ b/stack-lts-14.yaml @@ -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 diff --git a/stack-lts-15.yaml b/stack-lts-15.yaml index aea97b5..b672188 100644 --- a/stack-lts-15.yaml +++ b/stack-lts-15.yaml @@ -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 diff --git a/stack.yaml b/stack.yaml index 520043a..addd26d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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