reanimate-1.1.5.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 :: SVG -> SVG 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 :: SVG -> SVG Source #

Remove all id attributes.

clearDrawAttributes :: SVG -> SVG Source #

Remove all draw attributes such as stroke, fill and 'fill-opacity'.

simplify :: SVG -> SVG Source #

Optimize SVG tree without affecting how it is rendered.

removeGroups :: SVG -> [SVG] 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 :: SVG -> [PathCommand] Source #

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

withSubglyphs :: [Int] -> (SVG -> SVG) -> SVG -> SVG 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] -> SVG -> (SVG, SVG) Source #

Split symbols.

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

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

Split symbols and include their context and drawing attributes.

pathify :: SVG -> SVG 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.

boundingBox :: Tree -> (Double, Double, Double, Double) Source #

Return bounding box of SVG tree. The four numbers returned are (minimal X-coordinate, minimal Y-coordinate, width, height)

Note: Bounding boxes are computed on a best-effort basis and will not work in all cases. The only supported SVG nodes are: path, circle, polyline, ellipse, line, rectangle, image and svg. All other nodes return (0,0,0,0). The box for the svg node is based on the document's width and height (if both are present).

svgHeight :: Tree -> Double Source #

Height of SVG node in local units (not pixels). Computed on best-effort basis and will not give accurate results for all SVG nodes.

svgWidth :: Tree -> Double Source #

Width of SVG node in local units (not pixels). Computed on best-effort basis and will not give accurate results for all SVG nodes.

replaceUses :: Document -> Document Source #

Replace all use nodes with their definition.

unbox :: Document -> Tree Source #

Transform out viewbox. Definitions and CSS rules are discarded.

unboxFit :: Document -> Tree Source #

Transform out viewbox and fit image to screen size.

embedDocument :: Document -> Tree Source #

Embed Document. This keeps the entire document intact but makes it more difficult to use, say, pathify on it.