reanimate/examples/glue_tut_animate.hs
David Himmelstrup e39ec9e97f Animation snippet.
Former-commit-id: 71063b54ae11b766d22cdc7c19764c56084d11ab
2019-12-01 11:56:14 +08:00

48 lines
1.3 KiB
Haskell

#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where
import Reanimate
import Reanimate.Builtin.Documentation
import Reanimate.Builtin.Images
main :: IO ()
main = reanimate $ bg `parA` (animateCircleR `seqA` animateCircleP `seqA` animateRectR)
--(animateLogo)
where
bg = animate $ const $ mkBackground "white"
animateCircleR :: Animation
animateCircleR = mkAnimation 2 $ \t -> env $
mkGroup
[ mkCircle (t*2)
, withStrokeWidth 0 $ translate 0 3 $ scale 2 $
center $ latex "radius = t" ]
animateCircleP :: Animation
animateCircleP = mkAnimation 2 $ \t -> env $
mkGroup
[ partialSvg t (pathify $ mkCircle 2)
, withStrokeWidth 0 $ translate 0 3 $ scale 2 $
center $ latex "$\\% = t$" ]
animateRectR :: Animation
animateRectR = mkAnimation 2 $ \t -> env $
mkGroup
[ rotate (t*360) $ mkRect 4 2
, withStrokeWidth 0 $ translate 0 3 $ scale 2 $
center $ latex "rotation = t" ]
animateLogo :: Animation
animateLogo = mkAnimation 2 $ \t -> env $
mkGroup
[ partialSvg t haskellLogo
, withStrokeWidth 0 $ translate 0 3 $ scale 2 $
center $ latex "$\\% = t%" ]
env :: SVG -> SVG
env =
withStrokeColor "red" .
withFillColor "black" .
withStrokeWidth (defaultStrokeWidth*2)