This is bashscript is the main working horse of the makeart posterproduction. I tried to clean it out for the documentation here, since I realised that in the original script is a lot of code, which became unnecessary during the design process. For example we planned in the beginning to place the logo flexible inside the 3x3 grid. This was skipped at some point, because it was impossible this way, to gain the designated size for the logo. I will go through the script step by step and hope it will be comprehensible in some way.
Supplying with Arguments
Read more here about we supply the script with some arguments
Elements
The posters consist of different parts (logo, sponsors, information, generated graphics)
which are layouted with some help from LaTeX,
To produce graphics that will be used for the illustrative part of the posters, we use
separate scripts.
These generator scripts are stored in a folder
and randomly selected according to the current $GRIDNUMBER
–variable.
The suitability depends on the output complexity and filesize and is
stored in the header section of the scripts, e.g.
# SUITABLE FOR FOLLOWING GRIDS:,9,81,729,
We search via grep
for generator scripts, which include a line that matches the
pattern .*SUITABLE.*,$GRIDTYPE
. The option -H
prints the filepath of matching files (separated by a :). We separate the filepath from the
search pattern with cut -d ":" -f 1
, select one random line with rl --count=1
and print the filename only (without path): cut -d "/" -f 2
.
WHITECHECK=`grep "WHITE LOGO" i/$CANVASSCRIPT | wc -l` BLACKCHECK=`grep "BLACK LOGO" i/$CANVASSCRIPT | wc -l`if [ $BLACKCHECK -ge 1 ]; then LOGO=$LOGODIR/makeartwtf_black.pdf elif [ $WHITECHECK -ge 1 ]; then LOGO=$LOGODIR/makeartwtf_white.pdf else LOGO=`ls $LOGODIR/makeartwtf_*.pdf | rl --count=1` fiLCOLOR=`echo ${LOGO##*makeartwtf_}` INPUTFILE=`cat $LOGODIR/${LCOLOR%.*}.list | \ rl --count=1`echo $INPUTFILE > $TMP/file.i
In this step we define the logo. We can choose between a
black
and a
white
logo.
Which logo for which script depends on the amount of black of its output.
It was decided and noted in advance in the script header.
To find out about the prefered color we search for certain string (in this case
I WANT A BLACK LOGO !!!
))
with grep "BLACK LOGO" i/$CANVASSCRIPT | wc -l
.
If there is no prefered color we decide randomly.
Some of the generator scripts
use existing vector graphics as input.
These input files are dependent on the chosen logo color and defined in a list
(black or
white).
Naming and checking
The name of the final poster
is put together from generator script, grid type and logo position
(The logo position distinction is a relict when
there where 9 different positions,
one for each grid).
In the next step we test if there is already existing a poster with the same
configuration. If there is already existing a poster matching the name (= matching the
configuration) the script exits. The script may exit because it is triggered (= run again) by
another shellsript
until we have the desired amount of posters.
By the way: Although there is only one more logo position (PLACELOGO=1
),
we use the optional variable in the name (wtf_aut_0_02_081-
2
.pdf
) to allow
generator scripts, that produce random output to generate more than 1 poster.
If we find the string GENERATES RANDOM OUTPUT
)
in the script we just exclude the logo position variable from our CHECKEXIST
–pattern.
PLACELOGO=1PD=${CANVASSCRIPT%.*}_ FNA=`echo 00$GRIDTYPE| rev | cut -c 1-3 | rev`- ME=$PLACELOGOCHECKRANDOM=`grep "$ISRANDOM" i/$CANVASSCRIPT | wc -l`if [ $CHECKRANDOM -ge 1 ]; then CHECKEXIST=`find $OUTPUTFOLDER/$FORMAT -name "*$PD$FNA$ME*" | wc -l` else CHECKEXIST=`find $OUTPUTFOLDER/$FORMAT -name "*$PD$FNA*" | wc -l` fiif [ $CHECKEXIST -lt 1 ]; then
Now that we have defined our presets and checked if there is not already existing a poster with this configuration we can start the actual generating.
Getting things done
We change into the script directory
with cd
, execute the script and return to the main folder
with cd -
.
The standard output
of cd
is sent to /dev/null
(defined in the header with NIRVANA=/dev/null
)
because silence is golden
cd i 1> $NIRVANA ./$CANVASSCRIPT $INPUTFILE $GRIDTYPE cd - 1> $NIRVANA
We set the standard values for counting and define our graphic command for LaTeX including a special section (pleasing sections are defined in the generator script) and a optional border.
TEXGENERATED=$TMP/canvas.tex COLCOUNT=3 ROWCOUNT=3 COLCOUNTTWO=3 ROWCOUNTTWO=3 MAXGRIDS=9SECTOR=`grep SECTOR i/$CANVASSCRIPT | \ cut -d ":" -f 2 |\ rl --count=1` BORDER=`grep BORDER i/$CANVASSCRIPT | head -1 | cut -d ":" -f 2` BORDER=\{$BORDER\}############################ # GRAFIK COMMAND FOR LATEX # ############################createGRAFIK () {GRAFIKOPEN="\canvasgraphic{" GRAFIKCLOSE="}%"O=$GRAFIKOPEN; G=$GRAFIK C=$GRAFIKCLOSE ; S=$SECTOR; W=$WIDTHecho $O$G$C >> $TEXGENERATED echo $S$W >> $TEXGENERATED echo $BORDER >> $TEXGENERATED }####################################
In the next steps we write the tex file which will be included in our main tex file. We distinct between the 3 grids. Simplest grid is 3*3=9.
Different Grids
if [ $GRIDTYPE -eq 9 ]; then
We set the counts to 1 and write the variables that define the lengths in the tex file.
GRIDCOUNT=1 GRAFIKCOUNT=1echo "\setlength{\unitlength}%" > $TEXGENERATED echo "{\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATED
While the GRIDCOUNT
is less than our maximum amount of
grids we select one of the previously generated pdf files, each step
one file further, and write the graphic command with the appropriate path
into the tex file.
while [ $GRIDCOUNT -le $MAXGRIDS ] do echo "{%" >> $TEXGENERATEDGRAFIK=`ls $TMP/*.pdf | \ head -n $GRIDTYPE | \ head -n $GRAFIKCOUNT | \ tail -1` WIDTH="{width=.97\universalgrid}"createGRAFIKecho "}%" >> $TEXGENERATEDGRIDCOUNT=`expr $GRIDCOUNT + 1` GRAFIKCOUNT=`expr $GRAFIKCOUNT + 1` done
Here you can read a bit more about the listing method using head and tail
Our custom LateX grid macro can be supplied with a list of graphics and will automatically arrange them to our usual reading habit:
right to left, linebreak and again
This prescription made it a bit more complicated to place grids inside the grid.
If we use the same listing logic the visual order gets messed up.
If we place a grid in the grid (instead of graphics) and want to keep the visual order, we have to change the listing routine. We can’t simply write an ordered list into the LaTeX grid, but we have to differentiate at certain points.
elif [ $GRIDTYPE -eq 81 ]; thenGRIDCOUNT=1 GRAFIKCOUNT=1echo "\setlength{\unitlength}%" > $TEXGENERATED echo "{\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATEDwhile [ $GRIDCOUNT -le $MAXGRIDS ] do GRIDCOUNTTWO=1echo "{%" >> $TEXGENERATEDecho "\setlength{\unitlength}%" >> $TEXGENERATED echo "{.33\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATEDwhile [ $GRIDCOUNTTWO -le $MAXGRIDS ] do if [ $COLCOUNT -le 0 ]; thenCOLCOUNT=3 GRAFIKCOUNT=`expr $GRAFIKCOUNT + 6` fi echo "{%" >> $TEXGENERATEDGRAFIK=`ls $TMP/*.pdf | head -n $GRIDTYPE | \ head -n $GRAFIKCOUNT | \ tail -1` WIDTH="{width=.3\universalgrid}" createGRAFIKecho "}%" >> $TEXGENERATEDGRIDCOUNTTWO=`expr $GRIDCOUNTTWO + 1` GRAFIKCOUNT=`expr $GRAFIKCOUNT + 1` COLCOUNT=`expr $COLCOUNT - 1`doneecho "}%" >> $TEXGENERATEDGRIDCOUNT=`expr $GRIDCOUNT + 1` COLCOUNT=3 ROWCOUNT=`expr $ROWCOUNT - 1`if [ $ROWCOUNT -gt 0 ]; then GRAFIKCOUNT=`expr $GRAFIKCOUNT - 18` else ROWCOUNT=3 fi done
Finish
Now we have to just to prepare the notice for the generator
script and render the file with pdflatex
.
cp $LOGO $TMP/logo.pdf###################### # POSTER INFORMATION # ######################cat i/$CANVASSCRIPT | \ sed 's/\#/ /g' |\ sed 's/based on/poster graphics based on/g' > $TMP/script.sh######################### # DECIDE AND PLACE LOGO # #########################ISPROCESSING=`grep java i/$CANVASSCRIPT | wc -l` ISSHOEBOT=`grep SHOEBOT i/$CANVASSCRIPT | wc -l`if [ $ISPROCESSING -gt 0 ]; thencp $LOGODIR/processing.pdf $TMP/scriptlogo.pdfelif [ $ISSHOEBOT -gt 0 ]; thenecho TEST else cp $LOGODIR/bash.pdf $TMP/scriptlogo.pdf fipdflatex $FORMAT.tex &> $NIRVANA mv $FORMAT.pdf $OUTPUTFOLDER/$FORMAT/wtf_$PD$FNA$ME.pdfelse echo The File wtf_$PD$FNA$ME already exists fiexit 0;