Use gifs to improve documentation. (#21)

Former-commit-id: 40e5ccedcf5d1ca8f0d5cc373ba3b3c4cc2d6c6a
This commit is contained in:
David Himmelstrup 2019-09-28 21:35:42 +08:00 committed by GitHub
commit dfd52961ae
50 changed files with 512 additions and 129 deletions

45
docs/gen_gallery.sh Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
ROOT=`stack path --project-root`
EXAMPLES='boundingbox colormaps goo latex_basic latex_color latex_draw
latex_wheel raster sphere sunflower tangent_and_normal vector_field'
WIDTH=640
HEIGHT=$((WIDTH*9/16))
FPS=30
SRC_DIR=$ROOT/examples
DST_DIR=$ROOT/docs/rendered
OPTS='--fps $FPS --width $WIDTH --height $HEIGHT'
cat << EOF > $ROOT/docs/gallery.md
# Gallery
This file is auto-generated by docs/render_all.sh. DO NOT EDIT.
EOF
for e in $EXAMPLES; do
cat << EOF >> $ROOT/docs/gallery.md
## $e
<details>
<summary>View $e.hs</summary>
<pre><code class="haskell">
{!examples/$e.hs!}
</code></pre>
</details>
<br/>
<video width="$WIDTH" height="$HEIGHT" autoplay loop>
<source src="https://github.com/Lemmih/reanimate/raw/master/docs/rendered/$e.mp4">
</video>
<br/><hr><br/>
EOF
SRC_FILE=./$SRC_DIR/$e.hs
DST_FILE=./$DST_DIR/$e.mp4
if [[ "$SRC_FILE" -nt "$DST_FILE" ]]; then
stack $SRC_FILE render --compile -o $DST_FILE $OPTS
fi
done