Add more combinators.

This commit is contained in:
David Himmelstrup 2019-09-08 16:18:14 +08:00
commit 0992f6144b
2 changed files with 13 additions and 0 deletions

View file

@ -123,6 +123,13 @@ mapF fn frame = Frame $ \d t -> do
pauseAtEnd :: Double -> Animation -> Animation
pauseAtEnd p a = a `andThen` pause p
pauseAtBeginning :: Double -> Animation -> Animation
pauseAtBeginning d1 a =
Animation d1 (freezeFrame 0 a) `before` a
freezeFrame :: Double -> Animation -> Frame ()
freezeFrame t (Animation d f) = Frame $ \_ _ -> unFrame f d t
adjustSpeed :: Double -> Animation -> Animation
adjustSpeed factor (Animation d fn) =
Animation (d/factor) $ Frame $ \_dur t -> unFrame fn d (t*factor)

View file

@ -518,6 +518,9 @@ withFillColorPixel color = fillColor .~ pure (ColorRef color)
withFillOpacity :: Double -> Tree -> Tree
withFillOpacity opacity = fillOpacity .~ Just (realToFrac opacity)
withGroupOpacity :: Double -> Tree -> Tree
withGroupOpacity opacity = groupOpacity .~ Just (realToFrac opacity)
withStrokeWidth :: Number -> Tree -> Tree
withStrokeWidth width = strokeWidth .~ pure width
@ -557,6 +560,9 @@ mkDefinitions :: [Tree] -> Tree
mkDefinitions forest = DefinitionTree $ defaultSvg
& groupChildren .~ forest
mkUse :: String -> Tree
mkUse name = UseTree (defaultSvg & useName .~ name) Nothing
mkClipPath :: String -> [Tree] -> Tree
mkClipPath idTag forest = withId idTag $ ClipPathTree $ (defaultSvg
& clipPathContent .~ forest)