reanimate/examples/morphology_object_correspondence.hs
David Himmelstrup 4356efbc7e Feature morph (#62)
* Disable windows CI (because of hmatrix)
* Implement ear-clip triangulation.
* Implement common framework for polygon morphing.
* Draft implementations of compatible triangulation and mesh smoothing.
* Implement least-work morphing.
* Implement as-rigid-as-possible morphing.
* Implement SSSP.
* Draft article about polygon morphing.

Former-commit-id: f6f19f58b9dd58c655bcca0ed2d65f72726f0a06
2020-05-14 15:14:29 +08:00

59 lines
1.8 KiB
Haskell
Executable file

#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ParallelListComp #-}
module Main(main) where
import Codec.Picture
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) $
sceneAnimation $ do
let showLabel label = do
fork $ play $ staticFrame 4 (center $ latex label)
# mapA (translate 0 4)
# applyE (overBeginning 0.1 fadeInE)
# applyE (overEnding 0.1 fadeOutE)
let sides = mkGroup
[ translate (-4) 0 $ withFillColor "blue" $
mkCircle 2
, translate 4 0 $ withFillColor "green" $
mkCircle 2]
middle =
withFillColor "red" $
mkRect 4 4
showLabel "Cut"
play $ step sides middle
# pauseAtEnd 1
play $ step middle sides
# pauseAtEnd 1
showLabel "Overlap"
play $ stepDup sides middle
# pauseAtEnd 1
play $ stepDup middle sides
# pauseAtEnd 1
showLabel "Obliterate"
play $ stepGenesis sides middle
# pauseAtEnd 1
play $ stepGenesis middle sides
# pauseAtEnd 1
where
step from to =
signalA (curveS 2) $ animate $ morph linear from to
stepDup from to =
signalA (curveS 2) $ animate $ morph linear{morphObjectCorrespondence=dupObjectCorrespondence} from to
stepGenesis from to =
signalA (curveS 2) $ animate $ morph linear{morphObjectCorrespondence=genesisObjectCorrespondence} from to