Last active
June 11, 2020 20:26
-
-
Save rocktronica/4f33efbbfde3ced727244d89aca57553 to your computer and use it in GitHub Desktop.
openscad-png-by-commit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
*.png | |
*.gif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE: | |
# ./animate.sh SLUG FRAMERATE | |
# ./animate.sh development 3 | |
{ | |
set -e # stop script on error | |
slug="$1" | |
framerate="$2" | |
convert *.png -set delay 1x$framerate "$slug.gif" | |
gifsicle -O3 --colors 256 < "$slug.gif" > "$slug-256.gif" | |
gifsicle -O3 --colors 128 < "$slug.gif" > "$slug-128.gif" | |
gifsicle -O3 --colors 64 < "$slug.gif" > "$slug-064.gif" | |
gifsicle -O3 --colors 32 < "$slug.gif" > "$slug-032.gif" | |
gifsicle -O3 --colors 16 < "$slug.gif" > "$slug-016.gif" | |
gifsicle -O3 --colors 8 < "$slug.gif" > "$slug-008.gif" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
{ | |
set -e # stop script on error | |
openscad="/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" | |
output_dir="$PWD" | |
input_dir="$HOME/buttonpusher" | |
pushd "$input_dir" > /dev/null || exit | |
function cleanup() { | |
git checkout master --quiet | |
} | |
trap cleanup EXIT | |
for hash in $(git log master --pretty="format:%h" -- "*.scad"); do | |
previous_filename="$filename" | |
timestamp=$(git show $hash --quiet --pretty="format:%ct") | |
message=$(git show $hash --quiet --pretty="format:%f") | |
filename="$timestamp-$hash-$message.png" | |
git checkout "$hash" --quiet | |
# buttonpusher.scad or mount.scad, in that order | |
input_file=$(find . -name mount.scad -o -name buttonpusher.scad | sort | head -n1) | |
echo "$input_file -> $filename" | |
$openscad "$input_file" -o "$output_dir/$filename" \ | |
--viewall \ | |
--imgsize=1920,1080 \ | |
--colorscheme DeepOcean \ | |
--view=edges \ | |
--quiet | |
if [ -f "$output_dir/$previous_filename" ]; then | |
if [ -z "$(diff "$output_dir/$previous_filename" "$output_dir/$filename")" ]; then | |
rm "$output_dir/$previous_filename" | |
fi | |
fi | |
done | |
cleanup | |
popd > /dev/null || exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment