#!/bin/sh

# More complexe example based on the alien_letter.py script.
#
# Notice how the scaling of the large letters is relative instead of absolute (no `--to`
# option). This works because we know that the geometry generated by alien_letter.py
# is withing a (0 0 5 6) bounding box (this is the size of the underlying grid of the symbols).
# This is why the multiplication by 1.5cm in both direction works, although it can seem hacky.
#
# Also note a couple of syntax gotchas:
#
# 1) The use of the `--` end-of-options marker with translate command. This marker
# indicates that what follows are not options the command's arguments (in this case
# the offset by which to translate). This is necessary to avoid interpreting the
# minus sign in "-0.35cm" as option marker.
#
# 2) The `--to` option of the `scale` command does actually not take any argument. The
# corresponding line coud have been writen `scale --to -o 0 0 0.8cm 0.8cm`. The two factors
# are instead arguments of the `scale` command and must be passed after the options.

vpype begin grid -o 8cm 9.5cm 2 3 \
  script alien_letter.py \
  scale -o 0 0 1.5cm 1.5cm \
  translate -- -0.35cm -0.35cm \
  begin grid --offset 1.5cm 1.5cm 4 5 \
    script alien_letter.py \
    scale -o 0 0 --to 0.8cm 0.8cm \
  end \
end \
show \
write --page-size a4 --center alien2.svg