Files
puzzles/icons/screenshot.sh
Simon Tatham d55ad9fc42 New mechanism for automatic generation of the puzzle screenshots on
the web, which I hope will also end up being extended to generate
both Windows and X icons for each individual puzzle. The mechanism
is: for each puzzle there's a save file in the `icons' subdirectory
showing a game state which I think is a decent illustration of the
puzzle, and then there's a nasty set of scripts which runs each
puzzle binary, loads that save file, grabs a screenshot using xwd,
and munges it into shape.

In order to support this I've added two new options (--redo and
--windowid) to all the GTK puzzles, which I don't expect ever to be
used outside the icons makefile. I've also added two more options
(--load and --id) which force a GTK puzzle to treat its command-line
option as a save file or as a game ID respectively (the previous
behaviour was always to guess, and sometimes it guessed wrong).

[originally from svn r7014]
2006-12-26 16:47:28 +00:00

35 lines
978 B
Bash
Executable File

#!/bin/sh
# Generate a screenshot from a puzzle save file. Takes the
# following arguments, in order:
#
# - the name of the puzzle binary
# - the name of the save file
# - the name of the output image file
# - (optionally) the proportion of the next move to redo before
# taking the screenshot.
#
# This script requires access to an X server in order to run, but
# seems to work fine under xvfb-run if you haven't got a real one
# available (or if you don't want to use it for some reason).
binary="$1"
save="$2"
image="$3"
if test "x$4" != "x"; then
redo="--redo $4"
else
redo=
fi
"$binary" $redo --windowid --load "$save" 2>/dev/null | {
read windowid
# I'm not sure why I have to do this sleep, since gtk.c does
# carefully redraw the window _before_ outputting the window ID,
# but nonetheless this script doesn't seem to be reliable without
# it :-/
sleep 1
xwd -silent -id $windowid | convert xwd:- "$image"
xkill -id $windowid >/dev/null
}