#!/bin/bash

if [ "$1" ]; then
  SIZE="$1"
else
  echo "USAGE generate_background_pattern.sh SIZE (XxY)"
  exit 1
fi

  PATTERNS=( bricks checkerboard circles crosshatch crosshatch30 crosshatch45 fishscales \
            gray5 gray20 gray55 gray95 hexagons horizontal horizontalsaw hs_bdiagonal \
            hs_cross hs_diagcross hs_fdiagonal hs_horizontal hs_vertical left30 \
            left45 leftshingle octagons right30 right45 rightshingle smallfishscales \
            vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw )
  PATTERN=${PATTERNS[$(($RANDOM % 32))]}

  CONVERTSTRING=" -size ""$SIZE"
  CONVERTSTRING="$CONVERTSTRING"" pattern:""$PATTERN -normalize"
  CONVERTSTRING="$CONVERTSTRING"" -shade "$(($RANDOM % 150 +50))"x"$(($RANDOM % 60 +10))
  CONVERTSTRING="$CONVERTSTRING"" background.png"

  convert $CONVERTSTRING

exit 0
