shithub: sce

ref: 596459dd77e5c3e66a57be31e711a58624024881
dir: /utils/scesha/

View raw version
#!/bin/rc -e
if(! ~ $#* 6){
	echo usage: $0 fi fo Δx Δy sΔx sΔy
	exit usage
}
tmp=/tmp/scesha.$pid
fi=$1
fo=$2
Δx=$3
Δy=$4
sΔx=$5
sΔy=$6

cat <<EOF | pico
!r $fi f
f = z == 3 ? f[x,y,0] == 0 && f[x,y,1] == Z && f[x,y,2] == Z ? 0 : Z/2+1 : 0
m = y >= Y-($sΔy) ? 0 : f[x,y+($sΔy)]
m = x >= X-($sΔx) ? 0 : m[x+($sΔx),y]
r = z == 3 && m > 0 ? 0 : f
!w r $tmp
EOF

iconv -c a8r8g8b8 $tmp |\
	crop -t $Δx $Δy >$fo
rm $tmp