Casualty 14-18 ~ The making of a generative artwork by Richard Bolam – Part 6 #bolamat50 #casualty1418 #WW1

Screen shot 2014-08-02 at 16.40.24

This iteration of the software adds a random number individually colourised figures to the images.

I put in code to duplicate the basic figure, colourise it and then use it to individually overprint and colourise the black figures. I have highlighted the new code in a different colour. It uses the “composite” command and a dissolve operation to change the colour of the figures.

Although this is linux Bash scripting, I am doing the development on Mac OS X and I ran into a problem trying to get the loop working. On OS X there is no implementation of the “seq” command, which I believe is very widely used in Bash, but after a bit of googling, I found an workalike implementation as “gseq”, and this needs to be installed via coreutils in the usual way:

$ sudo port install coreutils

http://www.jaycehall.com/2008/11/04/seq-on-osx/

#!/bin/bash
#casualty make script v9
mkdir ‘Casualty1418-‘$(date +”%y_%m_%d”)
PATHNAME=’Casualty1418-‘$(date +”%y_%m_%d/”)
echo $PATHNAME

for i in {1..30}
do

#pad figure
convert casualty.png -gravity center -extent 20×38 casualtypad.png
convert casualtypad.png -transparent white casualtypad.png
convert casualtypad.png -fill “rgba($[RANDOM % 255],$[RANDOM % 255],$[RANDOM % 255])” -colorize 100% casualtycolour.png
convert casualtycolour.png -transparent white casualtycolour.png

#create tiled image of figures & make background transparent
convert -size 400×646 xc:white -composite tile:casualtypad.png casualtytiled.png
convert casualtytiled.png -transparent white casualtytiled.png

#colourise regions
REPEATS=$[1 + RANDOM % 20]
MAXWIDTH=$[$RANDOM %20]
MAXHEIGHT=$[$RANDOM %17]

for r in {1..3}
do

LEFT=$[$[RANDOM % 20]]
TOP=$[$[RANDOM % 17]]
RIGHT=$[$[RANDOM % (20 – $LEFT)]]
BOTTOM=$[$[RANDOM % (17 – $TOP)]]

echo $LEFT”,”$TOP”,”$RIGHT”,”$BOTTOM” – “$REPEATS
convert casualtytiled.png -region $[$LEFT * 20]x$[$TOP * 38]+$[$RIGHT * 20]+$[$BOTTOM * 38] -fill “rgba(255,255,255)” -colorize 20% casualtytiled.png
done

#add some individual figures
MAXCOUNT=$[RANDOM % 20]
echo $MAXCOUNT
for e in $( gseq $MAXCOUNT )
do
echo $e”/”$MAXCOUNT
composite -dissolve “$[RANDOM % 100],100” -geometry +$[($[RANDOM % 20]) * 20]+$[($[RANDOM % 17]) * 38] casualtycolour.png casualtytiled.png casualtytiled.png
done

#create page dimensions
convert casualtytiled.png -bordercolor white -border 99×90 casualtypage.png
convert casualtypage.png -gravity north -extent 598×850 casualtypage.png

#create label
convert -background white -font Gill-Sans -pointsize 10 -size 598×20 -gravity center label:’Casualty 14-18 ~ ‘$(date +”%d/%m/%y”)’ – ‘$(printf %02d $i) Casualtylabel.png

#composite page & label
FILENAME=’Casualty1418-‘$(date +”%y_%m_%d-“)$(printf %02d $i)’.png’

convert casualtypage.png -page +0+760 casualtylabel.png -layers flatten $PATHNAME$FILENAME

echo $PATHNAME$FILENAME

done

Casualty1418-14_08_02-20

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s