#! /bin/sh

# This script can be used to re-build the example files in this directory.
#
# Usage:
#   ./build
#
# This may take some minutes to complete.
# Change the number of iterations if you are impatient.
#
# Requirements:
#   R: http://www.r-project.org/
#   Ghostscript: http://www.ghostscript.com/

set -e

iterations="1000000"
slots="200"

../types --brief "$iterations" "$slots" < "input" > "type"
../types --brief --hapax "$iterations" "$slots" < "input" > "hapax"

R --vanilla --slave < plot.R

for a in "type" "hapax"; do
    gs \
        -dQUIET -dNOPAUSE -dBATCH \
        -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
        -sDEVICE=png16m -dEPSCrop \
        -sOutputFile="$a.png" "$a.eps"
done
