Use reanimate-svg-0.8.0.0

This commit is contained in:
David 2019-03-05 15:11:11 +01:00
commit 3527952da8
3 changed files with 13 additions and 14 deletions

View file

@ -115,7 +115,6 @@ renderSizedTree w h t = ppElement $ xmlOfDocument doc
, _elements = [t] , _elements = [t]
, _definitions = M.empty , _definitions = M.empty
, _description = "" , _description = ""
, _styleRules = []
, _documentLocation = "" , _documentLocation = ""
} }

View file

@ -36,7 +36,7 @@ replaceUses doc = doc & elements %~ map (mapTree replace)
Just tree -> Just tree ->
GroupTree $ GroupTree $
defaultSvg & groupChildren .~ [tree] defaultSvg & groupChildren .~ [tree]
& drawAttr .~ (defaultSvg & transform .~ Just [baseToTransformation (use^.useBase)]) & transform .~ Just [baseToTransformation (use^.useBase)]
replace x = x replace x = x
baseToTransformation (x,y) = baseToTransformation (x,y) =
case (toUserUnit defaultDPI x, toUserUnit defaultDPI y) of case (toUserUnit defaultDPI x, toUserUnit defaultDPI y) of
@ -46,7 +46,7 @@ replaceUses doc = doc & elements %~ map (mapTree replace)
idMap = foldTree updMap Map.empty docTree `Map.union` idMap = foldTree updMap Map.empty docTree `Map.union`
(doc^.definitions) (doc^.definitions)
updMap m tree = updMap m tree =
case tree^.drawAttr.attrId of case tree^.attrId of
Nothing -> m Nothing -> m
Just tid -> Map.insert tid tree m Just tid -> Map.insert tid tree m
elementToTree (ElementGeometry t) = Just t elementToTree (ElementGeometry t) = Just t
@ -58,7 +58,7 @@ docIds doc = Map.keys idMap ++ Map.keys (doc^.definitions)
docTree = GroupTree $ set groupChildren (doc^.elements) defaultSvg docTree = GroupTree $ set groupChildren (doc^.elements) defaultSvg
idMap = foldTree updMap Map.empty docTree idMap = foldTree updMap Map.empty docTree
updMap m tree = updMap m tree =
case tree^.drawAttr.attrId of case tree^.attrId of
Nothing -> m Nothing -> m
Just tid -> Map.insert tid tree m Just tid -> Map.insert tid tree m
@ -68,7 +68,7 @@ unbox :: Document -> Tree
unbox doc@Document{_viewBox = Just (minx, minw, _width, _height)} = unbox doc@Document{_viewBox = Just (minx, minw, _width, _height)} =
GroupTree $ defaultSvg GroupTree $ defaultSvg
& groupChildren .~ doc^.elements & groupChildren .~ doc^.elements
& drawAttr .~ (defaultSvg & transform .~ Just [Translate (-minx) (-minw)]) & transform .~ Just [Translate (-minx) (-minw)]
unbox doc = unbox doc =
GroupTree $ defaultSvg GroupTree $ defaultSvg
& groupChildren .~ doc^.elements & groupChildren .~ doc^.elements
@ -338,12 +338,12 @@ svgBoundingPoints t = map (Transform.transformPoint m) $
ImageTree{} -> [] ImageTree{} -> []
MeshGradientTree{} -> [] MeshGradientTree{} -> []
where where
m = Transform.mkMatrix (t^.drawAttr.transform) m = Transform.mkMatrix (t^.transform)
mapTuple f = f *** f mapTuple f = f *** f
withTransformations :: [Transformation] -> Tree -> Tree withTransformations :: [Transformation] -> Tree -> Tree
withTransformations transformations t = withTransformations transformations t =
mkGroup [t] & drawAttr %~ transform .~ Just transformations mkGroup [t] & transform .~ Just transformations
translate :: Double -> Double -> Tree -> Tree translate :: Double -> Double -> Tree -> Tree
translate x y = withTransformations [Translate x y] translate x y = withTransformations [Translate x y]
@ -407,22 +407,22 @@ mkColor name =
Just c -> ColorRef c Just c -> ColorRef c
withStrokeColor :: String -> Tree -> Tree withStrokeColor :: String -> Tree -> Tree
withStrokeColor color = drawAttr %~ strokeColor .~ pure (mkColor color) withStrokeColor color = strokeColor .~ pure (mkColor color)
withFillColor :: String -> Tree -> Tree withFillColor :: String -> Tree -> Tree
withFillColor color = drawAttr %~ fillColor .~ pure (mkColor color) withFillColor color = fillColor .~ pure (mkColor color)
withFillColorPixel :: PixelRGBA8 -> Tree -> Tree withFillColorPixel :: PixelRGBA8 -> Tree -> Tree
withFillColorPixel color = drawAttr %~ fillColor .~ pure (ColorRef color) withFillColorPixel color = fillColor .~ pure (ColorRef color)
withFillOpacity :: Double -> Tree -> Tree withFillOpacity :: Double -> Tree -> Tree
withFillOpacity opacity = drawAttr %~ fillOpacity .~ Just (realToFrac opacity) withFillOpacity opacity = fillOpacity .~ Just (realToFrac opacity)
withStrokeWidth :: Number -> Tree -> Tree withStrokeWidth :: Number -> Tree -> Tree
withStrokeWidth width = drawAttr %~ strokeWidth .~ pure width withStrokeWidth width = strokeWidth .~ pure width
withClipPathRef :: ElementRef -> Tree -> Tree withClipPathRef :: ElementRef -> Tree -> Tree
withClipPathRef ref = drawAttr %~ clipPathRef .~ pure ref withClipPathRef ref = clipPathRef .~ pure ref
mkRect :: Point -> Number -> Number -> Tree mkRect :: Point -> Number -> Number -> Tree
mkRect corner width height = RectangleTree $ defaultSvg mkRect corner width height = RectangleTree $ defaultSvg

View file

@ -3,7 +3,7 @@ resolver: lts-11.22
allow-newer: false allow-newer: false
extra-deps: extra-deps:
- reanimate-svg-0.7.0.0 - reanimate-svg-0.8.0.0
- diagrams-1.4@sha256:3e36369e84115b900fd9dcb570672a188339a470eb19ca62170775cd835cf8ca - diagrams-1.4@sha256:3e36369e84115b900fd9dcb570672a188339a470eb19ca62170775cd835cf8ca
- diagrams-contrib-1.4.3@sha256:bcfa6c85f8c33b8c48c3a61b7216afdebd51cd793c50da3a2dd358827d25fc76 - diagrams-contrib-1.4.3@sha256:bcfa6c85f8c33b8c48c3a61b7216afdebd51cd793c50da3a2dd358827d25fc76
- diagrams-core-1.4.1.1@sha256:6ef6b17785d77997c481eb085570e21b6a00cc91d086fbf49490504130ebc7d1 - diagrams-core-1.4.1.1@sha256:6ef6b17785d77997c481eb085570e21b6a00cc91d086fbf49490504130ebc7d1