reanimate/examples/polyshape_test4.hs
Jan Hrček 3d20cf49ef Fix some hlint warnings
Former-commit-id: e9b81a8bc0b0c99abe57644e8806c437759ca687
2019-12-11 07:50:27 +08:00

33 lines
1 KiB
Haskell
Executable file

#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Reanimate
import Reanimate.PolyShape
polygonTest :: Animation
polygonTest = mapA std $
let shapes = svgToPolyShapes $ center $ scale 6 $ latex "$\\infty$"
groups =
plGroupTouching $
map plFromPolygon $ plDecompose $ shapes
-- totalLen = sum $ map (maximum . map (plArea.snd)) groups
totalLen = fromIntegral $ length groups
anis = [ setDuration dur $ animate $ \t -> renderPolyShapes $ map (plPartial' t) group
| group <- groups
, let groupLen = 1 -- maximum (map (plArea.snd) group)
dur = groupLen/totalLen * totalT ]
in foldr andThen (pause 0) anis
where
totalT = 5
std =
withFillOpacity 1 .
withFillColor "blue" .
withStrokeWidth 0.00 .
withStrokeColor "white"
main :: IO ()
main = reanimate $ bg `parA` polygonTest
where
bg = animate $ const $ mkBackground "black"