Last active
August 29, 2015 14:15
-
-
Save carlynorama/69fffbbcd5d391006d69 to your computer and use it in GitHub Desktop.
This image scans the top left corner of an image for a green spot at particular locations. Shifted for use in the Moon Temple.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This image scans the top left corner of an image for a | |
#green spot at particular locations. | |
#Values shifted for use in the Moon Temple | |
#y values work for Manji Temple but not X | |
#Reduce time by running process for just the part of the | |
#grid actually represented | |
Y1=$1 | |
Y2=$2 | |
X1=$3 | |
X2=$4 | |
#used in prefix generation | |
ZPAD=2 | |
#folder files saved into | |
MYDIR="named_tiles" | |
#About the image being processed and where to look | |
#on the legend for the location information. | |
XOFFSET=269 | |
YOFFSET=87 | |
let KEYWIDTH=417-$XOFFSET | |
let KEYHEIGHT=207-$YOFFSET | |
NUM_X_POS=4 #how many tiles wide? | |
NUM_Y_POS=8 #how many tiles tall? | |
let XMULTIPLIER=${KEYWIDTH}/${NUM_X_POS} | |
let YMULTIPLIER=${KEYHEIGHT}/${NUM_Y_POS} | |
let XOFFSET=XOFFSET+XMULTIPLIER/2 | |
let YOFFSET=YOFFSET+YMULTIPLIER/2 | |
#What color on the legend indicates where I am. | |
TRUECOLOR="136,216,0" | |
#Some variables needed to generate the route I took if all | |
#the files are from the same day. | |
NL=$'\n' | |
MYROUTE="MY ROUTE:$NL" | |
ROUTEX=7 #if not far left tile, 0, then where? | |
ROUTEY=7 #if not top tile, 0, then where? | |
#The defaults if no variables are passed into the script. | |
if [[ -z $Y1 ]]; then Y1=0 ; fi | |
if [[ -z $Y2 ]]; then let Y2=${NUM_Y_POS}-1 ; fi | |
if [[ -z $X1 ]]; then X1=0 ; fi | |
if [[ -z $X2 ]]; then let X2=${NUM_X_POS}-1 ; fi | |
if [ ! -d ./${MYDIR} ]; then mkdir ./${MYDIR}; fi | |
# processes all pngs | |
if ls | grep png; then for p in *.png; do | |
echo "Processing $p" | |
found=0 | |
for i in $(seq $Y1 $Y2); do | |
let YCORD=${YOFFSET}+${i}*${YMULTIPLIER} | |
#FOR ROUTE TEXT | |
let YLOC=ROUTEY-${i} | |
for j in $(seq $X1 $X2); do | |
let XCORD=${XOFFSET}+${j}*${XMULTIPLIER} | |
#FOR ROUTE TEXT | |
let XLOC=ROUTEX-${j} | |
if [ "$XLOC" -ge 0 ] | |
then XDESC="E" | |
else XDESC="W" | |
fi | |
XLOC=${XLOC#-} | |
mycolor=$(convert $p[1x1+${XCORD}+${YCORD}] -format "%[fx:floor(255*u.r)],%[fx:floor(255*u.g)],%[fx:floor(255*u.b)]" info:-) | |
#echo "I look $mycolor at $XCORD, $YCORD" | |
if [ "$mycolor" == "$TRUECOLOR" ]; then | |
found=1 | |
#FOR ROUTE TEXT | |
printf -v location "%0*dN, %0*d%s" $ZPAD $YLOC $ZPAD $XLOC $XDESC | |
MYROUTE="${MYROUTE}${location}$NL" | |
#echo "I am at $location" | |
#FILE RENAME AND MOVE | |
printf -v fileprefix "%0*dy%0*dx" $ZPAD $i $ZPAD $j | |
cp -p $p ./${MYDIR}/${fileprefix}_${p} | |
#echo "I am at $filename" | |
break 2 | |
fi | |
done | |
done | |
if [ "$found" -lt 1 ] | |
then | |
cp -p $p ./${MYDIR}/HELP_${p} | |
fi | |
done | |
fi | |
echo "$MYROUTE" > route.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment