reanimate/examples/morphology_intro.hs
Jan Hrcek 0aca2333e2
Fix some hlint warnings, and more consistency in examples (#167)
* 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
2020-09-20 22:51:22 +08:00

36 lines
1.2 KiB
Haskell
Executable file

#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where
import Codec.Picture
import Control.Lens ((&))
import Reanimate
import Reanimate.Morph.Common
import Reanimate.Morph.Linear
bgColor :: PixelRGBA8
bgColor = PixelRGBA8 252 252 252 0xFF
main :: IO ()
main = reanimate $
addStatic (mkBackgroundPixel bgColor) $
mapA (withStrokeWidth 0) $
mapA (withStrokeColor "black") $
mapA (withFillOpacity 1) $
scene $ do
play $ step stage1 stage2
play $ step stage2 stage3
play $ step stage3 stage4
play $ step stage4 stage1
& setDuration 5
where
radius = 2.5
step from to =
signalA (curveS 4) $ animate $ morph linear from to
stage1 = translate (-3) 0 $ withFillColor "red" $ mkCircle radius
stage2 = translate 3 0 $ withFillColor "blue" $ mkRect (radius*2) (radius*2)
stage3 = mkGroup
[translate (-1) (-1) $ withFillColor "green" $ mkRect (radius*0.5) (radius*0.5)
,translate 1 1 $ withFillColor "black" $ mkRect (radius*0.5) (radius*0.5) ]
stage4 = translate (-3) 0 $ withFillColor "purple" $ mkCircle (radius*0.24)