diff --git a/examples/blender_default_cube.hs b/examples/blender_default_cube.hs index 6c01869..1baf662 100644 --- a/examples/blender_default_cube.hs +++ b/examples/blender_default_cube.hs @@ -6,7 +6,6 @@ module Main (main) where import Data.String.Here import Reanimate -import Reanimate.Blender main :: IO () main = reanimate $ mkAnimation 5 $ \t -> diff --git a/examples/blender_sphere.hs b/examples/blender_sphere.hs index 9b3c313..47b250a 100644 --- a/examples/blender_sphere.hs +++ b/examples/blender_sphere.hs @@ -7,8 +7,6 @@ module Main (main) where import Data.String.Here import qualified Data.Text as T import Reanimate -import Reanimate.Blender -import Reanimate.Raster main :: IO () main = reanimate $ mkAnimation 5 $ \t -> diff --git a/examples/latex_wheel.hs b/examples/latex_wheel.hs index ca7a126..a11daf0 100644 --- a/examples/latex_wheel.hs +++ b/examples/latex_wheel.hs @@ -8,7 +8,6 @@ import Control.Monad (forM_) import Graphics.SvgTree (Tree) import Reanimate import Reanimate.Driver (reanimate) -import Reanimate.Effect main :: IO () main = reanimate $ bg `parA` mainScene diff --git a/examples/tut_glue_animate.hs b/examples/tut_glue_animate.hs index 0a0a4f1..f16a05c 100644 --- a/examples/tut_glue_animate.hs +++ b/examples/tut_glue_animate.hs @@ -3,12 +3,10 @@ {-# LANGUAGE OverloadedStrings #-} module Main(main) where +import Reanimate + import Codec.Picture.Types import Data.Text (Text) -import Reanimate -import Reanimate.Animation -import Reanimate.Effect -import Reanimate.Scene bgColor :: PixelRGBA8 bgColor = PixelRGBA8 252 252 252 0xFF diff --git a/examples/tut_glue_blender.hs b/examples/tut_glue_blender.hs index 1bdb50e..1579039 100644 --- a/examples/tut_glue_blender.hs +++ b/examples/tut_glue_blender.hs @@ -2,24 +2,19 @@ -- stack runghc --package reanimate {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE BangPatterns #-} module Main (main) where -import Data.String.Here -import qualified Data.Text as T import Reanimate -import Reanimate.Blender -import Reanimate.Raster -import Reanimate.Scene -import Reanimate.Animation -import Reanimate.Effect -import Graphics.SvgTree -import System.Random -import System.Random.Shuffle + +import Codec.Picture.Types import Control.Lens ((^.)) import Control.Monad import Data.Monoid -import Codec.Picture.Types +import Data.String.Here +import qualified Data.Text as T +import Graphics.SvgTree +import System.Random +import System.Random.Shuffle main :: IO () main = seq texture $ reanimate $ pauseAtEnd 1 $ parA bg $ sceneAnimation $ do diff --git a/examples/tut_glue_keyframe.hs b/examples/tut_glue_keyframe.hs index dc4723a..e0f28f3 100644 --- a/examples/tut_glue_keyframe.hs +++ b/examples/tut_glue_keyframe.hs @@ -4,11 +4,10 @@ {-# LANGUAGE RecursiveDo #-} module Main (main) where +import Reanimate + import Control.Monad (forM_) import Graphics.SvgTree (Tree) -import Reanimate -import Reanimate.Driver (reanimate) -import Reanimate.Effect import Codec.Picture main :: IO () diff --git a/examples/tut_glue_latex.hs b/examples/tut_glue_latex.hs index 0c7b072..a8f2afc 100755 --- a/examples/tut_glue_latex.hs +++ b/examples/tut_glue_latex.hs @@ -3,15 +3,14 @@ {-# LANGUAGE OverloadedStrings #-} module Main (main) where +import Reanimate + import Codec.Picture import Codec.Picture.Types import Control.Lens ((^.)) import Control.Monad import Data.Monoid import Graphics.SvgTree -import Reanimate -import Reanimate.Effect -import Reanimate.Scene import System.Random import System.Random.Shuffle @@ -89,5 +88,5 @@ drawAnimation' mbSeed fillDur step svg = sceneAnimation $ do where shuf lst = case mbSeed of - Nothing -> lst + Nothing -> lst Just seed -> shuffle' lst (length lst) (mkStdGen seed) diff --git a/examples/tut_glue_potrace.hs b/examples/tut_glue_potrace.hs index 3af9a03..abafd99 100755 --- a/examples/tut_glue_potrace.hs +++ b/examples/tut_glue_potrace.hs @@ -4,32 +4,24 @@ {-# LANGUAGE QuasiQuotes #-} module Main (main) where +import Reanimate +import Reanimate.Povray (povraySlow') + import Codec.Picture import Control.Monad import Data.String.Here import Data.Text (Text) -import Reanimate -import Reanimate.Povray -import Reanimate.Raster -import Reanimate.Scene main :: IO () main = reanimate $ parA bg $ sceneAnimation $ do play $ mkAnimation drawDuration $ \t -> partialSvg t (wireframe (-45) 220) xRot <- newVar (-45) yRot <- newVar 220 - -- _ <- newSprite $ do - -- getX <- freezeVar xRot - -- getY <- freezeVar yRot - -- return $ \real_t dur t -> - -- povraySlow [] $ - -- script (svgAsPngFile (texture (t/dur))) (getX real_t) (getY real_t) 0 wf <- newSprite $ do getX <- freezeVar xRot getY <- freezeVar yRot return $ \real_t _dur _t -> wireframe (getX real_t) (getY real_t) - --wait 2 tweenVar yRot spinDur (\t v -> fromToS v (v+60*3) $ curveS 2 (t/spinDur)) replicateM_ wobbles $ do tweenVar xRot (wobbleDur/2) (\t v -> fromToS v (v+90) $ curveS 2 (t/(wobbleDur/2))) @@ -37,7 +29,6 @@ main = reanimate $ parA bg $ sceneAnimation $ do wait (wobbleDur/2) tweenVar xRot (wobbleDur/2) (\t v -> fromToS v (v-90) $ curveS 2 (t/(wobbleDur/2))) wait wobbleDur - --wait 2 destroySprite wf play $ mkAnimation drawDuration (\t -> partialSvg t (wireframe (-45) 220)) # reverseA @@ -60,26 +51,16 @@ wireframe rotX rotY = mkPath $ extractPath $ vectorize_ ["-t","100"] $ povraySlow' [] $ - script (svgAsPngFile texture) rotX rotY 0 + script (svgAsPngFile texture) rotX rotY texture :: SVG texture = checker 10 10 -script :: FilePath -> Double -> Double -> Double -> Text -script png rotX rotY rotZ = [iTrim| -//Files with predefined colors and textures +script :: FilePath -> Double -> Double -> Text +script png rotX rotY = [iTrim| #include "colors.inc" -#include "shapes3.inc" - //Place the camera -camera { - orthographic - location <0,0,-10> - look_at <0,0,0> - up y*9 - right x*16 -} camera { perspective location <0,0,-9> @@ -88,13 +69,10 @@ camera { right x*16/9 } - //Ambient light to "brighten up" darker pictures global_settings { ambient_light White*3 } //Set a background color -//background { color White } -//background { color rgbt <0.1, 0, 0, 0> } // red background { color rgbt <0, 0, 0, 1> } // transparent //Sphere with specified center point and radius @@ -105,16 +83,15 @@ sphere { image_map{ png ${png} } } } - rotate <0,${rotY},${rotZ}> + rotate <0,${rotY},0> rotate <${rotX},0,0> } - |] checker :: Int -> Int -> SVG checker w h = withStrokeColor "lightblue" $ - withStrokeWidth (defaultStrokeWidth/2) $ + withStrokeWidth (defaultStrokeWidth*4) $ mkGroup [ withStrokeWidth 0 $ withFillOpacity 0.8 $ mkBackground "white" diff --git a/examples/tut_glue_povray.hs b/examples/tut_glue_povray.hs index 8109373..7ad0059 100755 --- a/examples/tut_glue_povray.hs +++ b/examples/tut_glue_povray.hs @@ -4,6 +4,9 @@ {-# LANGUAGE QuasiQuotes #-} module Main (main) where +import Reanimate +import Reanimate.Povray (povraySlow) + import Codec.Picture import Codec.Picture.Types import Control.Lens ((^.)) @@ -12,12 +15,6 @@ import Data.Monoid import Data.String.Here import Data.Text (Text) import Graphics.SvgTree hiding (Text) -import Reanimate -import Reanimate.Animation -import Reanimate.Effect -import Reanimate.Povray -import Reanimate.Raster -import Reanimate.Scene import System.Random import System.Random.Shuffle diff --git a/examples/tut_glue_povray_ortho.hs b/examples/tut_glue_povray_ortho.hs index a84b5e6..643bc97 100755 --- a/examples/tut_glue_povray_ortho.hs +++ b/examples/tut_glue_povray_ortho.hs @@ -4,6 +4,9 @@ {-# LANGUAGE QuasiQuotes #-} module Main (main) where +import Reanimate +import Reanimate.Povray + import Codec.Picture import Codec.Picture.Types import Control.Lens ((^.)) @@ -12,12 +15,6 @@ import Data.Monoid import Data.String.Here import Data.Text (Text) import Graphics.SvgTree hiding (Text) -import Reanimate -import Reanimate.Animation -import Reanimate.Effect -import Reanimate.Povray -import Reanimate.Raster -import Reanimate.Scene import System.Random import System.Random.Shuffle diff --git a/examples/tut_glue_svg.hs b/examples/tut_glue_svg.hs index e74b60b..4f90b68 100755 --- a/examples/tut_glue_svg.hs +++ b/examples/tut_glue_svg.hs @@ -3,14 +3,13 @@ {-# LANGUAGE OverloadedStrings #-} module Main (main) where -import Data.Text (Text) import Reanimate import Reanimate.Builtin.Images -import Reanimate.Effect -import Reanimate.Scene -import Graphics.SvgTree hiding (Text) -import Control.Lens -import Codec.Picture + +import Codec.Picture +import Control.Lens +import Data.Text (Text) +import Graphics.SvgTree hiding (Text) bgColor :: PixelRGBA8 bgColor = PixelRGBA8 252 252 252 0xFF @@ -101,4 +100,3 @@ mkBlob = mkFilter :: String -> [FilterElement] -> Filter mkFilter ident fe = defaultSvg & filterChildren .~ fe & attrId .~ Just ident - diff --git a/src/Reanimate.hs b/src/Reanimate.hs index ffce199..7a6fb6d 100644 --- a/src/Reanimate.hs +++ b/src/Reanimate.hs @@ -26,10 +26,12 @@ module Reanimate reanimate, -- * Animations SVG, + Time, Animation(..), mkAnimation, animate, duration, + frameAt, -- ** Composition seqA, parA, @@ -71,6 +73,32 @@ module Reanimate wait, adjustZ , withSceneDuration, + newSprite, + newSpriteA, + destroySprite, + spriteE, + newVar, + tweenVar, + freezeVar, + + -- ** Effects + Effect, + overBeginning, + overEnding, + reverseE, + delayE, + applyE, + constE, + fadeInE, + fadeOutE, + fadeLineInE, + fadeLineOutE, + drawInE, + drawOutE, + fillInE, + translateE, + aroundCenterE, + transitions, -- * SVG module Reanimate.Svg.Constructors, @@ -82,11 +110,18 @@ module Reanimate embedDynamicImage, embedPng, raster, + svgAsPngFile, + vectorize, + vectorize_, -- ** External SVG providers latex, latexAlign, xelatex, + -- * External 3D renderers povray, + povray', + blender, + blender', -- * Colormaps turbo, viridis, @@ -112,16 +147,18 @@ module Reanimate ) where import Reanimate.Animation +import Reanimate.Blender import Reanimate.ColorMap import Reanimate.Constants import Reanimate.Driver import Reanimate.LaTeX +import Reanimate.Parameters import Reanimate.Povray import Reanimate.Raster +import Reanimate.Effect +import Reanimate.Scene import Reanimate.Signal import Reanimate.Svg import Reanimate.Svg.BoundingBox import Reanimate.Svg.Constructors import Reanimate.Svg.LineCommand -import Reanimate.Scene -import Reanimate.Parameters