From d499000eb66402d315072d87f88ac8f32ea89f01 Mon Sep 17 00:00:00 2001 From: David Himmelstrup Date: Tue, 21 Jul 2020 12:34:12 +0800 Subject: [PATCH] Host video files on B2. --- .gitignore | 1 + docs/glue_tut.md | 10 +++++++++ docs/sync_b2.sh | 36 +++++++++++++++++++++++++++++++ examples/tut_glue_potrace.hs | 2 +- examples/tut_glue_povray.hs | 2 +- examples/tut_glue_povray_ortho.hs | 2 +- 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100755 docs/sync_b2.sh diff --git a/.gitignore b/.gitignore index 8ee1bf9..ad12ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .stack-work +.b2 diff --git a/docs/glue_tut.md b/docs/glue_tut.md index a166391..5ee8538 100644 --- a/docs/glue_tut.md +++ b/docs/glue_tut.md @@ -25,6 +25,7 @@ SVG features, as demonstrated in the below animation:
@@ -40,6 +41,7 @@ Animations can be defined as SVG images over time (plus a bit of bookkeeping suc
@@ -53,6 +55,7 @@ Reanimate is not an opinionated framework, though, and also offers a more tradit
@@ -74,6 +77,7 @@ The following examples shows how something as seemingly complicated as fourier s
@@ -87,6 +91,7 @@ Scripting in Haskell also gives access to the extensive body of code libraries.
@@ -108,6 +113,7 @@ The resulting SVGs can be manipulated just like any other. The below examples il
@@ -123,6 +129,7 @@ Although incredibly expressive, SVGs are strictly limited to 2D graphics. This l
@@ -137,6 +144,7 @@ The video above uses a perspective camera, ie. objects further away appears to b
@@ -155,6 +163,7 @@ The example below uses built-in modifiers to bend a plane into a sphere and is r
@@ -170,5 +179,6 @@ The example below uses built-in modifiers to bend a plane into a sphere and is r
diff --git a/docs/sync_b2.sh b/docs/sync_b2.sh new file mode 100755 index 0000000..05e0281 --- /dev/null +++ b/docs/sync_b2.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +ROOT=`stack path --project-root` + +RENDER_OPTIONS='--compile --fps 60 --width 1920' +ANIMATIONS='tut_glue_svg + tut_glue_latex + tut_glue_animate + tut_glue_keyframe + tut_glue_blender + tut_glue_fourier + tut_glue_physics + tut_glue_potrace + tut_glue_povray + tut_glue_povray_ortho' + +B2_DIR=$ROOT/.b2 +B2_LISTING=$B2_DIR/directory.json +mkdir --parents $B2_DIR + +b2 ls --json --long reanimate > $B2_LISTING +cd $ROOT/examples/ +for BASE in $ANIMATIONS; do + SRC=$ROOT/examples/$BASE.hs + DST=$B2_DIR/$BASE.mp4 + echo $DST $SRC + if [[ "$SRC" -nt "$DST" ]]; then + #echo "stack $src render -o $DST $RENDER_OPTIONS" + stack $SRC render -o $DST $RENDER_OPTIONS + fi + SHA=($(sha1sum $DST)) + FILE_INFO=$(jq '.[] | select(.contentSha1=="'$SHA'") | .fileName' $B2_LISTING) + if [ -z "$FILE_INFO" ]; then + echo "Uploading $BASE..." + b2 upload-file --quiet --sha1 $SHA reanimate $DST $BASE.mp4 + fi +done diff --git a/examples/tut_glue_potrace.hs b/examples/tut_glue_potrace.hs index a97f031..436f37a 100755 --- a/examples/tut_glue_potrace.hs +++ b/examples/tut_glue_potrace.hs @@ -78,7 +78,7 @@ sphere { <0,0,0>, 3 texture { uv_mapping pigment{ - image_map{ png ${png_} } + image_map{ png "${png_}" } } } rotate <0,${rotY_},0> diff --git a/examples/tut_glue_povray.hs b/examples/tut_glue_povray.hs index 2b381ee..dee697c 100755 --- a/examples/tut_glue_povray.hs +++ b/examples/tut_glue_povray.hs @@ -75,7 +75,7 @@ polygon { <0, 0>, <0, 1>, <1, 1>, <1, 0> texture { pigment{ - image_map{ png ${png_} } + image_map{ png "${png_}" } } } translate <-1/2,-1/2> diff --git a/examples/tut_glue_povray_ortho.hs b/examples/tut_glue_povray_ortho.hs index 9247adb..f652b60 100755 --- a/examples/tut_glue_povray_ortho.hs +++ b/examples/tut_glue_povray_ortho.hs @@ -88,7 +88,7 @@ sphere { <0,0,0>, 4 texture { uv_mapping pigment{ - image_map{ png ${png_} } + image_map{ png "${png_}" } } } rotate <0,${rotY_},${rotZ_}>