#! /usr/bin/gawk -f # Last edited on 2018-06-16 23:47:12 by jstolfi # Converts pixel coordinates copied from a chart image to points in proper units. /^[ ]*([#]|$)/ { # Comment/blank: print; next; } /^[=]/ { # Scale definition: x0=$2; y0=$3; t0=$4; p0=$5; x1=$6; y1=$7; t1=$8; p1=$9; print; next; } // { # Remove any previously mapped values: gsub(/[ ]*[#][#].*$/, "", $0); } /^[*]/ { t = xsc($2); p = ysc($3); printf "%s ## %6.2f %6.2f\n", $0, t, p; next; } /^[-]/ { ta = xsc($2); pa = ysc($3); tb = xsc($4); pb = ysc($5); printf "%s ## %6.2f %6.2f %6.2f %6.2f\n", $0, ta, pa, tb, pb; next; } //{ # Duh? print "%s ## ** ERROR\n", $0; next; } function xsc(x) { return t0 + (x-x0)*(t1-t0)/(x1-x0); } function ysc(y) { return p0 + (y-y0)*(p1-p0)/(y1-y0); }