reanimate-0.4.2.0: Animation library based on SVGs.

CopyrightWritten by David Himmelstrup
LicenseUnlicense
Maintainerlemmih@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Reanimate.Svg

Description

 
Synopsis

Documentation

lowerTransformations :: Tree -> Tree Source #

Remove transformations (such as translations, rotations, scaling) and apply them directly to the SVG nodes. Note, this function may convert nodes (such as Circle or Rect) to paths. Also note that does change how the SVG is rendered. Particularly, stroke width is affected by directly applying scaling.

lowerTransformations (scale 2 (mkCircle 1)) = mkCircle 2

lowerIds :: Tree -> Tree Source #

Remove all id attributes.

simplify :: Tree -> Tree Source #

Optimize SVG tree without affecting how it is rendered.

removeGroups :: Tree -> [Tree] Source #

Separate grouped items. This is required by clip nodes.

removeGroups (withFillColor "blue" $ mkGroup [mkCircle 1, mkRect 1 1])
    = [ withFillColor "blue" $ mkCircle 1
      , withFillColor "blue" $ mkRect 1 1 ]

extractPath :: Tree -> [PathCommand] Source #

Extract all path commands from a node (and its children) and concatenate them.

withSubglyphs :: [Int] -> (Tree -> Tree) -> Tree -> Tree Source #

Map over indexed symbols.

withSubglyphs [0,2] (scale 2) (mkGroup [mkCircle 1, mkRect 2, mkEllipse 1 2])
      = mkGroup [scale 2 (mkCircle 1), mkRect 2, scale 2 (mkEllipse 1 2)]

splitGlyphs :: [Int] -> Tree -> (Tree, Tree) Source #

Split symbols.

splitGlyphs [0,2] (mkGroup [mkCircle 1, mkRect 2, mkEllipse 1 2])
      = ([mkRect 2], [mkCircle 1, mkEllipse 1 2])

svgGlyphs :: Tree -> [(Tree -> Tree, DrawAttributes, Tree)] Source #

Split symbols and include their context and drawing attributes.

pathify :: Tree -> Tree Source #

Convert primitive SVG shapes (like those created by mkCircle, mkRect, mkLine or mkEllipse) into SVG path. This can be useful for creating animations of these shapes being drawn progressively with partialSvg.

Example:

pathifyExample :: Animation
pathifyExample = animate $ \t -> gridLayout
    [ [ partialSvg t $ pathify $ mkCircle 1
      , partialSvg t $ pathify $ mkRect 2 2
      ]
    , [ partialSvg t $ pathify $ mkEllipse 1 0.5
      , partialSvg t $ pathify $ mkLine (-1, -1) (1, 1)
      ]
    ]

mapSvgPaths :: ([PathCommand] -> [PathCommand]) -> SVG -> SVG Source #

Map over all recursively-found path commands.

mapSvgLines :: ([LineCommand] -> [LineCommand]) -> SVG -> SVG Source #

Map over all recursively-found line commands.

mapSvgPoints :: (RPoint -> RPoint) -> SVG -> SVG Source #

Map over all line command control points.

svgPointsToRadians :: SVG -> SVG Source #

Convert coordinate system from degrees to radians.