Set viewbox to 16 by 9. (#11)

* Set viewbox to 16 by 9.

* Update examples and fix process termination bug in driver.

* Add module for constants.


Former-commit-id: 1c77569e771455e674485e2fc58ee57e7df5f3c5
This commit is contained in:
David Himmelstrup 2019-09-18 19:20:14 +08:00 committed by GitHub
commit 89905ebe39
24 changed files with 167 additions and 121 deletions

View file

@ -11,14 +11,15 @@ import Reanimate.LaTeX
import Reanimate.Monad
import Reanimate.Svg
import Reanimate.Signal
import Reanimate.Constants
main :: IO ()
main = reanimate bbox
bbox :: Animation
bbox = bg `sim`
mapA (translate (-50) 0) bbox1 `sim`
mapA (translate 50 0) bbox2
mapA (translate (-screenWidth/4) 0) bbox1 `sim`
mapA (translate (screenWidth/4) 0) bbox2
where
bg = mkAnimation 0 $ emit $ mkBackground "black"
@ -29,14 +30,15 @@ bbox1 = mkAnimation 5 $ do
[ mkBoundingBox $ rotate (360*s) svg
, withFillColor "white" $ rotate (360*s) svg ]
where
svg = scale 3 $ center $ latexAlign "\\sum_{k=1}^\\infty"
svg = scale 2 $ center $ latexAlign "\\sum_{k=1}^\\infty"
bbox2 :: Animation
bbox2 = autoReverse $ mkAnimation 2.5 $ do
s <- getSignal signalLinear
emit $ mkGroup
[ mkBoundingBox $ partialSvg s heartShape
, withStrokeColor "white" $ withFillOpacity 0 $ partialSvg s heartShape ]
, withStrokeColor "white" $ withFillOpacity 0 $
partialSvg s heartShape ]
mkBoundingBox :: Tree -> Tree
mkBoundingBox svg = withStrokeColor "red" $ withFillOpacity 0 $
@ -45,7 +47,7 @@ mkBoundingBox svg = withStrokeColor "red" $ withFillOpacity 0 $
where
(x, y, w, h) = boundingBox svg
heartShape =
heartShape = lowerTransformations $ scaleXY 1 (-1) $ scale 0.1 $
center $ rotateAroundCenter 225 $ mkPathString
"M0.0,40.0 v-40.0 h40.0\
\a20.0 20.0 90.0 0 1 0.0,40.0\