#!/bin/sh

# tool
# usage: ./print_mounted_overlay.sh > ./mounted_overlay.sh && ln -sf mounted_overlay.svg layer3
#

print_mounted_overlay() { # {{{1
# adapted from /usr/sbin/fatdog-drive-icon-roxlib.sh
  local xh yh wh hh ph xph xpwh yph yphh sx sy
  xh=${HOTSPOT_X:-0} yh=${HOTSPOT_Y:-0}
  wh=${HOTSPOT_W:-12} hh=${HOTSPOT_H:-12} ph=${HOTSPOT_P:-2}
  xph=$(($xh + $ph)) xpwh=$(($xh + $ph + $wh)) yph=$(($yh + $ph)) yphh=$(($yh + $ph + $hh))

  # emblem originally designed for 96x96, we scale it for 12x12 hotspot
  # parameter: scaling 0.25, offset -3,-24, dimension is 24x24
  # with 0.25 scaling and 24x24 wxh (so wh & hh must be multiplied by 2)
  set -- $(awk "BEGIN{print $wh/(12*4),$hh/(12*4)}"); sx=$1 sy=$2
  echo "\
<svg width=\"48\" height=\"48\" id=\"svg1\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
<rect x=\"$xph\" y=\"$yph\" width=\"$wh\" height=\"$hh\" fill=\"#00ff00\" stroke=\"black\" stroke-width=\"2\"/>
<line x1=\"$xph\" y1=\"$yph\" x2=\"$xpwh\" y2=\"$yphh\" stroke=\"black\"/>
<line x1=\"$xph\" y1=\"$yphh\" x2=\"$xpwh\" y2=\"$yph\" stroke=\"black\"/>
</svg>"
}

print_mounted_overlay
