Skip to content

Instantly share code, notes, and snippets.

@rocktronica

rocktronica/.gitignore

Last active Jun 11, 2020
Embed
What would you like to do?
openscad-png-by-commit
.DS_Store
*.png
*.gif
#!/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"
}
#!/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
You can’t perform that action at this time.