reanimate/examples/polyshape_test4.hs
David Himmelstrup 8c80964260 Fix warnings.
Former-commit-id: 614999e27660c5816c82846253823cd0d821a6b1
2019-10-10 12:36:47 +08:00

33 lines
1 KiB
Haskell

#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
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 plLength) groups
anis = [ setDuration dur $ animate $ \t -> renderPolyShapes $ plPartialGroup t group
| group <- groups
, let groupLen = maximum (map plLength 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"