Add example to readme.

Former-commit-id: a871f528242402cddc59a37ce3b1dfaa0473bf12
This commit is contained in:
David 2019-02-17 14:12:45 +01:00
commit 458e6be3ed

View file

@ -8,6 +8,30 @@ The example gifs are rendered at 25 fps.
# Examples
## Drawing latex equations
```haskell
latex_draw :: Ani ()
latex_draw = pauseAtEnd 1 $ defineAnimation $ proc () -> do
emit -< rect_ [width_ "100%", height_ "100%", fill_ "black"]
drawText msg `andThen` fillText msg -< ()
where
msg = "\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}"
placement = g_ [transform_ $ translate 20 15 <> " " <> scale 5 5]
fillText txt = defineAnimation $ proc () -> do
duration 1 -< ()
s <- signal 0 1 -< ()
emit -< placement $
g_ [fill_ "white", num_ fill_opacity_ s] $
toHtml $ latexAlign txt
drawText txt = defineAnimation $ proc () -> do
duration 2 -< ()
s <- signal 0 1 -< ()
emit -< placement $
g_ [stroke_ "white", fill_opacity_ "0", stroke_width_ "0.1"] $
toHtml $ partialSvg s $ latexAlign txt
```
![Drawing LaTeX equations](gifs/latex_draw.gif)
## Bezier curves
![Bezier curves](gifs/bezier.gif)