#! /bin/gawk -f # Last edited on 2003-04-07 12:55:42 by stolfi BEGIN { usage = ( \ "draw-gridpoints \\\n" \ " [ -v scale=NUM ] \\\n" \ " < image.grpts > image.pcmds" \ ); # Outputs a string of commands, suitable as the "-draw" option # of "convert", that draws circles around the reference points # Assumes that it will be used on a copy of the image that has been # scaled by {scale}. abort = -1; } (abort >= 0) { exit abort; } ($6 ~ /^grid[0-9][0-9]/) { if (($5 + 0) != 0) { data_error(("bad Z = \"" $5 "\"")); } h = int(scale*$1); v = int(scale*$2); x = $3; y = $4; z = $5; printf "circle %d,%d %d,%d text %d,%d \"%d,%d\"\n", h,v, h+2,v, h+4,v+3, int(x/10 + 0.5), int(y/10 + 0.5); } END { if (abort >= 0) { exit abort; } } function data_error(msg) { printf "%d: **%s\n", FNR, msg > "/dev/stderr"; abort = 1; exit abort; } function arg_error(msg) { printf "**%s\n", msg > "/dev/stderr"; abort = 1; exit abort; }