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

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

for i in {1..30}

#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]

for r in {1..3}

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

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

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

#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




Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s