mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-10 15:42:21 +00:00
* Remove redundant brackets * Various hlint fixes * Remove unused language pragrams and other fixes * Use addStatic more consistently in examples * Rename remaining usages of sceneAnimation to scene
55 lines
1.5 KiB
Haskell
Executable file
55 lines
1.5 KiB
Haskell
Executable file
#!/usr/bin/env stack
|
|
-- stack runghc --package reanimate
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
module Main(main) where
|
|
|
|
import Reanimate
|
|
import Reanimate.Transition
|
|
|
|
import Codec.Picture.Types
|
|
import Data.Text (Text)
|
|
|
|
bgColor :: PixelRGBA8
|
|
bgColor = PixelRGBA8 252 252 252 0xFF
|
|
|
|
segmentDuration :: Double
|
|
segmentDuration = 3
|
|
|
|
transitionTime :: Double
|
|
transitionTime = 0.5
|
|
|
|
main :: IO ()
|
|
main = reanimate $ addStatic bg $
|
|
chainT transition
|
|
[animateCircleR, animateCircleP, animateRectR, animateColor
|
|
,signalA (constantS 0) $ setDuration transitionTime animateCircleR]
|
|
where
|
|
transition = overlapT transitionTime fadeT
|
|
bg = mkBackgroundPixel bgColor
|
|
|
|
animateCircleR :: Animation
|
|
animateCircleR = mkSegment "radius" $ \t -> mkCircle (t*2)
|
|
|
|
animateCircleP :: Animation
|
|
animateCircleP = mkSegment "drawn" $ \t ->
|
|
withFillOpacity 0 $ partialSvg t (pathify $ mkCircle 2)
|
|
|
|
animateRectR :: Animation
|
|
animateRectR = mkSegment "rotation" $ \t -> rotate (t*360) $ mkRect 4 2
|
|
|
|
animateColor :: Animation
|
|
animateColor = mkSegment "color" $ \t ->
|
|
withFillColorPixel (promotePixel $ turbo t) $ mkRect 4 2
|
|
|
|
mkSegment :: Text -> (Time -> SVG) -> Animation
|
|
mkSegment label gen = mkAnimation segmentDuration $ \t -> env $
|
|
mkGroup
|
|
[ gen t
|
|
, withStrokeWidth 0 $ translate 0 3 $ scale 2 $
|
|
center $ latex label ]
|
|
|
|
env :: SVG -> SVG
|
|
env =
|
|
withStrokeColor "red" .
|
|
withFillColor "black" .
|
|
withStrokeWidth (defaultStrokeWidth*2)
|