This script pro­duces an adver­tis­ing that was pub­lished in neural mag. As usual we start by defin­ing some global variables.

TMPDIR=i/tmp
LOGODIR=i/free/v/logos/layered/chmod+x_logo_100105/
LOGOLIST=$TMPDIR/vektor.list
TEMPTEX=neural.tex
PDFDIR=$TMPDIR
LAYERS=$TMPDIR/layers.list 
PDFS=$TMPDIR/pdfs.list 
OUTPUTDIR=o/free/neural
 
rm $TMPDIR/*

We use a pro­cess­ing sketch that takes a svg file and draws on the path infor­ma­tion given by this file. We define the para­me­ters to exe­cute the pro­cess­ing sketch as usual.

ren­der­ing

The chmod+x logo was sep­a­rated into lay­ers. The pro­cess­ing sketch now runs on every file (=layer) in the direc­tory. The out­put file­names are unique for each file (=layer) so they can be eas­ily sorted and rearranged later on. The pro­cess­ing script is called inside a for–loop, the input file­names are writ­ten into a textfile which is read by pro­cess­ing.

for PDF in `find $LOGODIR -name "*.svg" | sort`
 do
  echo $PDF > $LOGOLIST
  java  -Djava.library.path="$APPDIR" \
        -cp "$LIBS" \
    chmod_x_shodo4neural_02 
 done   

select­ing

Pro­cess­ing has ren­dered ten dif­fer­ent frames for each file/layer and out­put as pdf file. These pdf files get sorted and ref­er­enced in a list.

CNT=0
 
while [ $CNT -lt 10 ] do ls $PDFDIR/*.pdf | \ cut -d "_" -f 1 | \ cut -d "-" -f 1 | \ sort | uniq > $LAYERS rm $PDFS

I wanted lay­ers to be treated dif­fer­ent. Some to appear more often, and for cer­tain lay­ers only cer­tain frames (egrep '0001|00002|00003').

IMPORTANTLAYERS="5 6 6 2 2 7 7 7 8 8 8"
VIPLAYERS="5 6"
 
COUNT=1 for LAYER in `cat $LAYERS` do ls $LAYER* | \ grep -v 00000 | \ egrep '0001|00002|00003' | \ rl --count=1 >> $PDFS
 
for L in $IMPORTANTLAYERS; do if [ $COUNT -eq $L ]; then
 
ls $LAYER* | grep -v 00000 | rl --count=2 >> $PDFS
 
fi done for L in $VIPLAYERS; do if [ $COUNT -eq $L ]; then
 
echo $PDFDIR/99_`find $PDFDIR -name "${LAYER##*/}*" |\ grep 00000 |\ xargs -l basename` >> $PDFS
 
fi done COUNT=`expr $COUNT + 1` done

lay­out­ing (=overlaying)

Layouting/Overlaying of pdf-files is done with LaTeX. Because some of the LaTeX code needs to be gen­er­ated by a script any­way, I decided to let the script write the whole tex file. Most of the LaTeX code is sta­tic, only a small sec­tion is writ­ten each time, because there need dif­fer­ent graphic files to be ref­er­enced. This is done with a for–loop.

for PDF in `cat $PDFS | sort | sed 's/99_//'`
    do
       echo  "\put(0,0){\graphic{"$PDF"}}"       >> $TEMPTEX
    done

This loop pro­duces the fol­low­ing LaTeX Code:

\begin{picture}(0,0)
\put(0,0){\graphic{i/tmp/143759--00002.pdf}}
\put(0,0){\graphic{i/tmp/143831--00002.pdf}}
\put(0,0){\graphic{i/tmp/143831--00003.pdf}}
\put(0,0){\graphic{i/tmp/143831--00007.pdf}}
\put(0,0){\graphic{i/tmp/143831--00009.pdf}}
\put(0,0){\graphic{i/tmp/143831--00010.pdf}}
\put(0,0){\graphic{i/tmp/143911--00003.pdf}}
\put(0,0){\graphic{i/tmp/144009--00002.pdf}}
\put(0,0){\graphic{i/tmp/144045--00002.pdf}}
\put(0,0){\graphic{i/tmp/144045--00002.pdf}}
\put(0,0){\graphic{i/tmp/144045--00004.pdf}}
\put(0,0){\graphic{i/tmp/144118--00004.pdf}}
\put(0,0){\graphic{i/tmp/144118--00005.pdf}}
\put(0,0){\graphic{i/tmp/144118--00008.pdf}}
\put(0,0){\graphic{i/tmp/144118--00009.pdf}}
\put(0,0){\graphic{i/tmp/144118--00010.pdf}}
\put(0,0){\graphic{i/tmp/144157--00001.pdf}}
\put(0,0){\graphic{i/tmp/144157--00001.pdf}}
\put(0,0){\graphic{i/tmp/144157--00003.pdf}}
\put(0,0){\graphic{i/tmp/144157--00006.pdf}}
\put(0,0){\graphic{i/tmp/144157--00008.pdf}}
\put(0,0){\graphic{i/tmp/144157--00009.pdf}}
\put(0,0){\graphic{i/tmp/144157--00010.pdf}}
\put(0,0){\graphic{i/tmp/144234--00001.pdf}}
\put(0,0){\graphic{i/tmp/144234--00001.pdf}}
\put(0,0){\graphic{i/tmp/144234--00001.pdf}}
\put(0,0){\graphic{i/tmp/144234--00002.pdf}}
\put(0,0){\graphic{i/tmp/144234--00009.pdf}}
\put(0,0){\graphic{i/tmp/144234--00009.pdf}}
\put(0,0){\graphic{i/tmp/144234--00010.pdf}}
\put(0,0){\graphic{i/tmp/144045--00000.pdf}}
\put(0,0){\graphic{i/tmp/144118--00000.pdf}}
\end{picture}
\end{document}

Finally the gen­er­ated LaTeX-file is com­piled with with pdflatex, given a unique file­name and moved to a directory.

UNIQUE=`date +%s`
pdflatex -output-directory $OUTPUTDIR $TEMPTEX
mv $OUTPUTDIR/${TEMPTEX%%.*}.pdf $OUTPUTDIR/neural--$UNIQUE-$CNT.pdf
rm $TEMPTEX
CNT=`expr $CNT + 1`
 
done
 
exit 0;

The script cre­ates 10 dif­fer­ent pdfs from which one can be selected accord­ing to per­sonal taste.