Skip to content

Instantly share code, notes, and snippets.

@t-paul
Created February 15, 2014 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-paul/9024903 to your computer and use it in GitHub Desktop.
Save t-paul/9024903 to your computer and use it in GitHub Desktop.
#!/bin/bash
CNT=0
WINID=$(xwininfo -name "OpenSCAD - test.scad" | grep "Window id:" | awk '{ print $4; }')
NUM=${1-50}
echo "Using ${NUM}x${NUM} cube area..."
while true
do
echo "" > /tmp/test.scad
for x in $(seq 0 $NUM)
do
for y in $(seq 0 $NUM)
do
echo -n "translate([$x, $y, 0]) { scale([0.8,0.8,0.8]) { " >> /tmp/test.scad
echo -n "cube(1); " >> /tmp/test.scad
echo -n "}" >> /tmp/test.scad
echo "}" >> /tmp/test.scad
done
done
#cp slow-render.scad /tmp/test.scad ; sleep 0.1; echo "translate([$RANDOM / 1000, 0, 0]) color(\"red\") cylinder(r = 2, h = 40);" >> /tmp/test.scad
echo "translate([$RANDOM / 1000, 0, 0]) color(\"red\") cylinder(r = 2, h = 40);" >> /tmp/test.scad
sleep 2
import -window 0x2e00003 img.png
REDPIXEL=$(convert img.png -fuzz 20% -fill black +opaque red -fill white -opaque red -print "%[fx:w*h*mean]" null: | sed -e 's/\..*//')
echo "$(date): $REDPIXEL"
if [ $REDPIXEL -lt 100 ]
then
cp img.png $(printf "err_%04d.img" $CNT)
CNT=$(expr $CNT + 1)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment