reanimate-0.1.8.0: Animation library based on SVGs.

Reanimate

Description

Reanimate is an animation library based on SVGs. It is designed to act like glue between external components such as latex, ffmpeg, gnuplot, diagrams, and povray.

Synopsis

# Driver

Reanimate features a web-based viewer which is opened by default if no other parameters are given. Key features:

• This viewer listens for changes to the source file and recompiles the code automatically as needed.
• Animations are rendered with increasing fidelity until the frame rate eaches 60 fps.
• Key commands for pausing, frame stepping, forward/rewind.

Main entry-point for accessing an animation. Creates a program that takes the following command-line arguments:

Usage: PROG [COMMAND]
This program contains an animation which can either be viewed in a web-browser
or rendered to disk.

Available options:
-h,--help                Show this help text

Available commands:
check                    Run a system's diagnostic and report any missing
external dependencies.
view                     Play animation in browser window.
render                   Render animation to file.

Neither the check nor the view command take any additional arguments. Rendering animation can be controlled with these arguments:

Usage: PROG render [-o|--target FILE] [--fps FPS] [-w|--width PIXELS]
[-h|--height PIXELS] [--compile] [--format FMT]
[--preset TYPE]
Render animation to file.

Available options:
-o,--target FILE         Write output to FILE
--fps FPS                Set frames per second.
-w,--width PIXELS        Set video width.
-h,--height PIXELS       Set video height.
--compile                Compile source code before rendering.
--format FMT             Video format: mp4, gif, webm
--preset TYPE            Parameter presets: youtube, gif, quick
-h,--help                Show this help text

# Animations

type SVG = Tree Source #

data Animation Source #

Animations are SVGs over a finite time.

Constructors

 Animation Duration (Time -> SVG)

animate :: (Time -> SVG) -> Animation Source #

Construct animation with a duration of 1.

Query the duration of an animation.

## Composition

Play animations in sequence. The lhs animation is removed after it has completed. New animation duration is 'duration lhs + duration rhs'.

Example:

drawBox seqA drawCircle

Play two animation concurrently. Shortest animation freezes on last frame. New animation duration is 'max (duration lhs) (duration rhs)'.

Example:

drawBox parA adjustDuration (*2) drawCircle

Play two animation concurrently. Shortest animation loops. New animation duration is 'max (duration lhs) (duration rhs)'.

Example:

drawBox parLoopA adjustDuration (*2) drawCircle

Play two animation concurrently. Animations disappear after playing once. New animation duration is 'max (duration lhs) (duration rhs)'.

Example:

drawBox parLoopA adjustDuration (*2) drawCircle

Empty animation (no SVG output) with a fixed duration.

Example:

pause 1 seqA drawProgress

Play left animation and freeze on the last frame, then play the right animation. New duration is 'duration lhs + duration rhs'.

Example:

drawBox andThen drawCircle

mapA :: (Tree -> Tree) -> Animation -> Animation Source #

Map over the SVG produced by an animation at every frame.

Example:

mapA (scale 0.5) drawCircle

Freeze the last frame for t seconds at the end of the animation.

Example:

pauseAtEnd 1 drawProgress

Freeze the first frame for t seconds at the beginning of the animation.

Example:

pauseAtBeginning 1 drawProgress

Freeze the first and the last frame of the animation for a specified duration.

Example:

pauseAround 1 1 drawProgress

Change the duration of an animation. Animates are stretched or squished (rather than truncated) to fit the new duration.

Set the duration of an animation by adjusting its playback rate. The animation is still played from start to finish without being cropped.

Play an animation in reverse. Duration remains unchanged. Shorthand for: signalA reverseS.

Example:

reverseA drawCircle

Play animation before playing it again in reverse. Duration is twice the duration of the input.

Example:

playThenReverseA drawCircle

Loop animation n number of times. This number may be fractional and it may be less than 1. It must be greater than or equal to 0, though. New duration is n*duration input.

Example:

repeatA 1.5 drawCircle

Modify the time component of an animation. Animation duration is unchanged.

Example:

signalA (fromToS 0.25 0.75) drawCircle

## Signals

type Signal = Double -> Double Source #

Signals are time-varying variables. Signals can be composed using function composition.

Constant signal.

Example:

signalA (constantS 0.5) drawProgress

Signal with new starting and end values.

Example:

signalA (fromToS 0.8 0.2) drawProgress

Reverse signal order.

Example:

signalA reverseS drawProgress

S-curve signal. Takes a steepness parameter. 2 is a good default.

Example:

signalA (curveS 2) drawProgress

Bell-curve signal. Takes a steepness parameter. 2 is a good default.

Example:

signalA (bellS 2) drawProgress

Oscillate signal.

Example:

signalA oscillateS drawProgress

## Scenes

(#) :: a -> (a -> b) -> b Source #

data Scene s a Source #

Instances
 Monad (Scene s) Source # Instance detailsDefined in Reanimate.Scene Methods(>>=) :: Scene s a -> (a -> Scene s b) -> Scene s b #(>>) :: Scene s a -> Scene s b -> Scene s b #return :: a -> Scene s a #fail :: String -> Scene s a # Functor (Scene s) Source # Instance detailsDefined in Reanimate.Scene Methodsfmap :: (a -> b) -> Scene s a -> Scene s b #(<$) :: a -> Scene s b -> Scene s a # Source # Instance detailsDefined in Reanimate.Scene Methodsmfix :: (a -> Scene s a) -> Scene s a # Source # Instance detailsDefined in Reanimate.Scene Methodspure :: a -> Scene s a #(<*>) :: Scene s (a -> b) -> Scene s a -> Scene s b #liftA2 :: (a -> b -> c) -> Scene s a -> Scene s b -> Scene s c #(*>) :: Scene s a -> Scene s b -> Scene s b #(<*) :: Scene s a -> Scene s b -> Scene s a # sceneAnimation :: (forall s. Scene s a) -> Animation Source # fork :: Scene s a -> Scene s a Source # waitAll :: Scene s a -> Scene s a Source # adjustZ :: (ZIndex -> ZIndex) -> Scene s a -> Scene s a Source # # SVG ## Raster data ## External SVG providers Invoke latex and import the result as an SVG object. SVG objects are cached to improve performance. Example: latex "$e^{i\\pi}+1=0\$"

Invoke latex and import the result as an SVG object. SVG objects are cached to improve performance. This wraps the TeX code in an 'align*' context.

Example:

latexAlign "R = \\frac{{\\Delta x}}{{kA}}"

Invoke xelatex and import the result as an SVG object. SVG objects are cached to improve performance. Xelatex has support for non-western scripts.

Example:

xelatex "中文"

# Colormaps

Given a number t in the range [0,1], returns the corresponding color from the “turbo” color scheme by Anton Mikhailov.

Given a number t in the range [0,1], returns the corresponding color from the “viridis” perceptually-uniform color scheme designed by van der Walt, Smith and Firing for matplotlib, represented as an RGB string.

Given a number t in the range [0,1], returns the corresponding color from the “magma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, represented as an RGB string.

Given a number t in the range [0,1], returns the corresponding color from the “inferno” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, represented as an RGB string.

Given a number t in the range [0,1], returns the corresponding color from the “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, represented as an RGB string.

Given a number t in the range [0,1], returns the corresponding color from the “sinebow” color scheme by Jim Bumgardner and Charlie Loyd.

Parula is the default colormap for matlab.

Given a number t in the range [0,1], returns the corresponding color from the “cividis” color vision deficiency-optimized color scheme designed by Nuñez, Anderton, and Renslow, represented as an RGB string.

Jet colormap. Used to be the default in matlab. Obsolete.

hsv colormap. Goes from 0 degrees to 360 degrees.

Matlab hsv colormap. Goes from 0 degrees to 330 degrees.

Greyscale colormap.