mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-12 00:23:08 +00:00
Clean up examples.
Former-commit-id: 03934429a7a98d8c2891452e802e348a0456886a
This commit is contained in:
parent
07f47b92b0
commit
f10bc16726
12 changed files with 72 additions and 79 deletions
|
|
@ -6,7 +6,6 @@ module Main (main) where
|
||||||
|
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import Reanimate
|
import Reanimate
|
||||||
import Reanimate.Blender
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = reanimate $ mkAnimation 5 $ \t ->
|
main = reanimate $ mkAnimation 5 $ \t ->
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ module Main (main) where
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Reanimate
|
import Reanimate
|
||||||
import Reanimate.Blender
|
|
||||||
import Reanimate.Raster
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = reanimate $ mkAnimation 5 $ \t ->
|
main = reanimate $ mkAnimation 5 $ \t ->
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import Control.Monad (forM_)
|
||||||
import Graphics.SvgTree (Tree)
|
import Graphics.SvgTree (Tree)
|
||||||
import Reanimate
|
import Reanimate
|
||||||
import Reanimate.Driver (reanimate)
|
import Reanimate.Driver (reanimate)
|
||||||
import Reanimate.Effect
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = reanimate $ bg `parA` mainScene
|
main = reanimate $ bg `parA` mainScene
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Main(main) where
|
module Main(main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
|
||||||
import Codec.Picture.Types
|
import Codec.Picture.Types
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Reanimate
|
|
||||||
import Reanimate.Animation
|
|
||||||
import Reanimate.Effect
|
|
||||||
import Reanimate.Scene
|
|
||||||
|
|
||||||
bgColor :: PixelRGBA8
|
bgColor :: PixelRGBA8
|
||||||
bgColor = PixelRGBA8 252 252 252 0xFF
|
bgColor = PixelRGBA8 252 252 252 0xFF
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,19 @@
|
||||||
-- stack runghc --package reanimate
|
-- stack runghc --package reanimate
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
{-# LANGUAGE BangPatterns #-}
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
import Data.String.Here
|
|
||||||
import qualified Data.Text as T
|
|
||||||
import Reanimate
|
import Reanimate
|
||||||
import Reanimate.Blender
|
|
||||||
import Reanimate.Raster
|
import Codec.Picture.Types
|
||||||
import Reanimate.Scene
|
|
||||||
import Reanimate.Animation
|
|
||||||
import Reanimate.Effect
|
|
||||||
import Graphics.SvgTree
|
|
||||||
import System.Random
|
|
||||||
import System.Random.Shuffle
|
|
||||||
import Control.Lens ((^.))
|
import Control.Lens ((^.))
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Monoid
|
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 :: IO ()
|
||||||
main = seq texture $ reanimate $ pauseAtEnd 1 $ parA bg $ sceneAnimation $ do
|
main = seq texture $ reanimate $ pauseAtEnd 1 $ parA bg $ sceneAnimation $ do
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@
|
||||||
{-# LANGUAGE RecursiveDo #-}
|
{-# LANGUAGE RecursiveDo #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
|
||||||
import Control.Monad (forM_)
|
import Control.Monad (forM_)
|
||||||
import Graphics.SvgTree (Tree)
|
import Graphics.SvgTree (Tree)
|
||||||
import Reanimate
|
|
||||||
import Reanimate.Driver (reanimate)
|
|
||||||
import Reanimate.Effect
|
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,14 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
import Codec.Picture.Types
|
import Codec.Picture.Types
|
||||||
import Control.Lens ((^.))
|
import Control.Lens ((^.))
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
import Graphics.SvgTree
|
import Graphics.SvgTree
|
||||||
import Reanimate
|
|
||||||
import Reanimate.Effect
|
|
||||||
import Reanimate.Scene
|
|
||||||
import System.Random
|
import System.Random
|
||||||
import System.Random.Shuffle
|
import System.Random.Shuffle
|
||||||
|
|
||||||
|
|
@ -89,5 +88,5 @@ drawAnimation' mbSeed fillDur step svg = sceneAnimation $ do
|
||||||
where
|
where
|
||||||
shuf lst =
|
shuf lst =
|
||||||
case mbSeed of
|
case mbSeed of
|
||||||
Nothing -> lst
|
Nothing -> lst
|
||||||
Just seed -> shuffle' lst (length lst) (mkStdGen seed)
|
Just seed -> shuffle' lst (length lst) (mkStdGen seed)
|
||||||
|
|
|
||||||
|
|
@ -4,32 +4,24 @@
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
import Reanimate.Povray (povraySlow')
|
||||||
|
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Reanimate
|
|
||||||
import Reanimate.Povray
|
|
||||||
import Reanimate.Raster
|
|
||||||
import Reanimate.Scene
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = reanimate $ parA bg $ sceneAnimation $ do
|
main = reanimate $ parA bg $ sceneAnimation $ do
|
||||||
play $ mkAnimation drawDuration $ \t -> partialSvg t (wireframe (-45) 220)
|
play $ mkAnimation drawDuration $ \t -> partialSvg t (wireframe (-45) 220)
|
||||||
xRot <- newVar (-45)
|
xRot <- newVar (-45)
|
||||||
yRot <- newVar 220
|
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
|
wf <- newSprite $ do
|
||||||
getX <- freezeVar xRot
|
getX <- freezeVar xRot
|
||||||
getY <- freezeVar yRot
|
getY <- freezeVar yRot
|
||||||
return $ \real_t _dur _t ->
|
return $ \real_t _dur _t ->
|
||||||
wireframe (getX real_t) (getY real_t)
|
wireframe (getX real_t) (getY real_t)
|
||||||
--wait 2
|
|
||||||
tweenVar yRot spinDur (\t v -> fromToS v (v+60*3) $ curveS 2 (t/spinDur))
|
tweenVar yRot spinDur (\t v -> fromToS v (v+60*3) $ curveS 2 (t/spinDur))
|
||||||
replicateM_ wobbles $ do
|
replicateM_ wobbles $ do
|
||||||
tweenVar xRot (wobbleDur/2) (\t v -> fromToS v (v+90) $ curveS 2 (t/(wobbleDur/2)))
|
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)
|
wait (wobbleDur/2)
|
||||||
tweenVar xRot (wobbleDur/2) (\t v -> fromToS v (v-90) $ curveS 2 (t/(wobbleDur/2)))
|
tweenVar xRot (wobbleDur/2) (\t v -> fromToS v (v-90) $ curveS 2 (t/(wobbleDur/2)))
|
||||||
wait wobbleDur
|
wait wobbleDur
|
||||||
--wait 2
|
|
||||||
destroySprite wf
|
destroySprite wf
|
||||||
play $ mkAnimation drawDuration (\t -> partialSvg t (wireframe (-45) 220))
|
play $ mkAnimation drawDuration (\t -> partialSvg t (wireframe (-45) 220))
|
||||||
# reverseA
|
# reverseA
|
||||||
|
|
@ -60,26 +51,16 @@ wireframe rotX rotY =
|
||||||
mkPath $ extractPath $
|
mkPath $ extractPath $
|
||||||
vectorize_ ["-t","100"] $
|
vectorize_ ["-t","100"] $
|
||||||
povraySlow' [] $
|
povraySlow' [] $
|
||||||
script (svgAsPngFile texture) rotX rotY 0
|
script (svgAsPngFile texture) rotX rotY
|
||||||
|
|
||||||
texture :: SVG
|
texture :: SVG
|
||||||
texture = checker 10 10
|
texture = checker 10 10
|
||||||
|
|
||||||
script :: FilePath -> Double -> Double -> Double -> Text
|
script :: FilePath -> Double -> Double -> Text
|
||||||
script png rotX rotY rotZ = [iTrim|
|
script png rotX rotY = [iTrim|
|
||||||
//Files with predefined colors and textures
|
|
||||||
#include "colors.inc"
|
#include "colors.inc"
|
||||||
|
|
||||||
#include "shapes3.inc"
|
|
||||||
|
|
||||||
//Place the camera
|
//Place the camera
|
||||||
camera {
|
|
||||||
orthographic
|
|
||||||
location <0,0,-10>
|
|
||||||
look_at <0,0,0>
|
|
||||||
up y*9
|
|
||||||
right x*16
|
|
||||||
}
|
|
||||||
camera {
|
camera {
|
||||||
perspective
|
perspective
|
||||||
location <0,0,-9>
|
location <0,0,-9>
|
||||||
|
|
@ -88,13 +69,10 @@ camera {
|
||||||
right x*16/9
|
right x*16/9
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Ambient light to "brighten up" darker pictures
|
//Ambient light to "brighten up" darker pictures
|
||||||
global_settings { ambient_light White*3 }
|
global_settings { ambient_light White*3 }
|
||||||
|
|
||||||
//Set a background color
|
//Set a background color
|
||||||
//background { color White }
|
|
||||||
//background { color rgbt <0.1, 0, 0, 0> } // red
|
|
||||||
background { color rgbt <0, 0, 0, 1> } // transparent
|
background { color rgbt <0, 0, 0, 1> } // transparent
|
||||||
|
|
||||||
//Sphere with specified center point and radius
|
//Sphere with specified center point and radius
|
||||||
|
|
@ -105,16 +83,15 @@ sphere {
|
||||||
image_map{ png ${png} }
|
image_map{ png ${png} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rotate <0,${rotY},${rotZ}>
|
rotate <0,${rotY},0>
|
||||||
rotate <${rotX},0,0>
|
rotate <${rotX},0,0>
|
||||||
}
|
}
|
||||||
|
|
||||||
|]
|
|]
|
||||||
|
|
||||||
checker :: Int -> Int -> SVG
|
checker :: Int -> Int -> SVG
|
||||||
checker w h =
|
checker w h =
|
||||||
withStrokeColor "lightblue" $
|
withStrokeColor "lightblue" $
|
||||||
withStrokeWidth (defaultStrokeWidth/2) $
|
withStrokeWidth (defaultStrokeWidth*4) $
|
||||||
mkGroup
|
mkGroup
|
||||||
[ withStrokeWidth 0 $
|
[ withStrokeWidth 0 $
|
||||||
withFillOpacity 0.8 $ mkBackground "white"
|
withFillOpacity 0.8 $ mkBackground "white"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
import Reanimate.Povray (povraySlow)
|
||||||
|
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
import Codec.Picture.Types
|
import Codec.Picture.Types
|
||||||
import Control.Lens ((^.))
|
import Control.Lens ((^.))
|
||||||
|
|
@ -12,12 +15,6 @@ import Data.Monoid
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Graphics.SvgTree hiding (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
|
||||||
import System.Random.Shuffle
|
import System.Random.Shuffle
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Reanimate
|
||||||
|
import Reanimate.Povray
|
||||||
|
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
import Codec.Picture.Types
|
import Codec.Picture.Types
|
||||||
import Control.Lens ((^.))
|
import Control.Lens ((^.))
|
||||||
|
|
@ -12,12 +15,6 @@ import Data.Monoid
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Graphics.SvgTree hiding (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
|
||||||
import System.Random.Shuffle
|
import System.Random.Shuffle
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,13 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
import Data.Text (Text)
|
|
||||||
import Reanimate
|
import Reanimate
|
||||||
import Reanimate.Builtin.Images
|
import Reanimate.Builtin.Images
|
||||||
import Reanimate.Effect
|
|
||||||
import Reanimate.Scene
|
import Codec.Picture
|
||||||
import Graphics.SvgTree hiding (Text)
|
import Control.Lens
|
||||||
import Control.Lens
|
import Data.Text (Text)
|
||||||
import Codec.Picture
|
import Graphics.SvgTree hiding (Text)
|
||||||
|
|
||||||
bgColor :: PixelRGBA8
|
bgColor :: PixelRGBA8
|
||||||
bgColor = PixelRGBA8 252 252 252 0xFF
|
bgColor = PixelRGBA8 252 252 252 0xFF
|
||||||
|
|
@ -101,4 +100,3 @@ mkBlob =
|
||||||
|
|
||||||
mkFilter :: String -> [FilterElement] -> Filter
|
mkFilter :: String -> [FilterElement] -> Filter
|
||||||
mkFilter ident fe = defaultSvg & filterChildren .~ fe & attrId .~ Just ident
|
mkFilter ident fe = defaultSvg & filterChildren .~ fe & attrId .~ Just ident
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,12 @@ module Reanimate
|
||||||
reanimate,
|
reanimate,
|
||||||
-- * Animations
|
-- * Animations
|
||||||
SVG,
|
SVG,
|
||||||
|
Time,
|
||||||
Animation(..),
|
Animation(..),
|
||||||
mkAnimation,
|
mkAnimation,
|
||||||
animate,
|
animate,
|
||||||
duration,
|
duration,
|
||||||
|
frameAt,
|
||||||
-- ** Composition
|
-- ** Composition
|
||||||
seqA,
|
seqA,
|
||||||
parA,
|
parA,
|
||||||
|
|
@ -71,6 +73,32 @@ module Reanimate
|
||||||
wait,
|
wait,
|
||||||
adjustZ ,
|
adjustZ ,
|
||||||
withSceneDuration,
|
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
|
-- * SVG
|
||||||
module Reanimate.Svg.Constructors,
|
module Reanimate.Svg.Constructors,
|
||||||
|
|
@ -82,11 +110,18 @@ module Reanimate
|
||||||
embedDynamicImage,
|
embedDynamicImage,
|
||||||
embedPng,
|
embedPng,
|
||||||
raster,
|
raster,
|
||||||
|
svgAsPngFile,
|
||||||
|
vectorize,
|
||||||
|
vectorize_,
|
||||||
-- ** External SVG providers
|
-- ** External SVG providers
|
||||||
latex,
|
latex,
|
||||||
latexAlign,
|
latexAlign,
|
||||||
xelatex,
|
xelatex,
|
||||||
|
-- * External 3D renderers
|
||||||
povray,
|
povray,
|
||||||
|
povray',
|
||||||
|
blender,
|
||||||
|
blender',
|
||||||
-- * Colormaps
|
-- * Colormaps
|
||||||
turbo,
|
turbo,
|
||||||
viridis,
|
viridis,
|
||||||
|
|
@ -112,16 +147,18 @@ module Reanimate
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Reanimate.Animation
|
import Reanimate.Animation
|
||||||
|
import Reanimate.Blender
|
||||||
import Reanimate.ColorMap
|
import Reanimate.ColorMap
|
||||||
import Reanimate.Constants
|
import Reanimate.Constants
|
||||||
import Reanimate.Driver
|
import Reanimate.Driver
|
||||||
import Reanimate.LaTeX
|
import Reanimate.LaTeX
|
||||||
|
import Reanimate.Parameters
|
||||||
import Reanimate.Povray
|
import Reanimate.Povray
|
||||||
import Reanimate.Raster
|
import Reanimate.Raster
|
||||||
|
import Reanimate.Effect
|
||||||
|
import Reanimate.Scene
|
||||||
import Reanimate.Signal
|
import Reanimate.Signal
|
||||||
import Reanimate.Svg
|
import Reanimate.Svg
|
||||||
import Reanimate.Svg.BoundingBox
|
import Reanimate.Svg.BoundingBox
|
||||||
import Reanimate.Svg.Constructors
|
import Reanimate.Svg.Constructors
|
||||||
import Reanimate.Svg.LineCommand
|
import Reanimate.Svg.LineCommand
|
||||||
import Reanimate.Scene
|
|
||||||
import Reanimate.Parameters
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue