lbarchive/READYT

Xmahjongg: Mahjong solitaire

Closed this issue · 0 comments

Video

thumb

Script for still images

#!/bin/bash
# Written by Yu-Jie Lin in 2016 for making Xmahjongg video
# Public domain

takeshot()
{
  local NAME='xmahjongg'
  local W=1280 H=720
  local FONT='Envy Code R'

  # prepare xmj
  src/$NAME --config-dir share --geometry 1280x720 "$@" &
  local XMJ_PID=$!
  sleep 0.5

  # take shot
  # ref: http://blog.yjl.im/2015/08/xsnap-usage.html#e077-region
  local FILE='/tmp/$NAME.tmp.png'
  xsnap -region ${W}x${H}+2+20 -file "$FILE"

  # add cmd text
  # ref: http://www.imagemagick.org/Usage/annotating/#anno_on
  local FILE_T="/tmp/$NAME $@.png"
  local CMD="$NAME $@"
  local G=8
  local G_T=$G
  local H_T=12
  local RECT="$G,$((H - H_T - G - 2 * G_T)),$((W - G)),$((H - G))"
  local TPOS="+$((G + G_T))+$((H - G - G_T))"
  convert "$FILE"                                 \
          -font "$FONT" -pointsize 20             \
          -fill '#0008' -draw "rectangle $RECT"   \
          -fill  white  -annotate "$TPOS" "$CMD"  \
          "$FILE_T"

  kill $XMJ_PID
  rm "$FILE"
}

LAYOUTS=(
  arena   arrow      boar     bridge  ceremonial  deepwell  default  dog
  dragon  farandole  hare     horse   hourglass   monkey    ox       papillon
  ram     rat        rooster  schoon  snake       theater   tiger    wedges
)
TILESETS=(dorothys  dorwhite  gnome  gnome2  real  small  thick  thin)
BACKGROUNDS=(default  green)
TOTAL_L=${#LAYOUTS[@]}
TOTAL_T=${#TILESETS[@]}
TOTAL_BG=${#BACKGROUNDS[@]}
for ((L = 0; L < TOTAL_L; L++)); do
  ((T = L * TOTAL_T  / TOTAL_L))
  ((B = L * TOTAL_BG / TOTAL_L))
  takeshot                    \
    --bg ${BACKGROUNDS[B]}    \
    --tileset ${TILESETS[T]}  \
    --layout ${LAYOUTS[L]}
done