EDIT: Success! Influence to 0 change nothing, and influence to .5 shows a smooth transition, and influence to 1 is full effect.
Thank you for your support of helping! @afre @garagecoder
iw={w}
ih={h}
is={s}
ws=1
axis=0
threshold_var=0
influence_var=.5
shift_var={($ws+1)/2}
dir={$axis?($ws>=0?1:-1):($ws<0?1:-1)}
s c
l. alpha_max={iM}
alpha_middle={iM/2}
endl
f. $threshold_var>0?($threshold_var==1?(i<(1-10^-8)*$alpha_max?0:i):(i<$threshold_var*$alpha_max?0:i)):i
a c
+channels {$is-1}
f. i==0?0:$alpha_max
if $axis
+shift. 0,$dir negate.
else
+shift. $dir,0 negate.
fi
+add[-1,-2]
/. 2 rm.. rv[^0] a[^0] c
l.
+select_color 0,$alpha_middle,0
f.. "
const step = max(1,0%*min(w,h));
const angle = (0*90)*pi/180;
const dx = step*cos(angle);
const dy = step*sin(angle);
if (!i(#-1),I,
ixf = xf = x; iyf = yf = y; lf = 0;
while (i(#-1,ixf=round(xf),iyf=round(yf)), ++lf; xf-=dx; yf-=dy);
ixb = xb = x; iyb = yb = y; lb = 0;
while (i(#-1,ixb=round(xb),iyb=round(yb)), ++lb; xb+=dx; yb+=dy);
(lb*lb*I(ixf,iyf) + lf*lf*I(ixb,iyb))/(lb^2+lf^2);
)"
channels 0
f.. "i#0==i#1?1:i"
rm.
f $influence_var>0?($influence_var==1?(i<(1-10^-8)*$alpha_max?0:i):(i<($influence_var*$alpha_max)?0:i)):i
f i!=0?i+$alpha_max
endl
s c
l[-2,-1] f.. "i==0?i#1:i" endl
rm.
a c
if $axis>0
s x
repeat $! l[$>] r 1,{h+1},100%,100%,0,0,.5,1 autocrop_components ,,,, a y r 1,$ih,100%,100%,0,0,.5,{1-$shift_var} endl done
a x
else
s y
repeat $! l[$>] r {w+1},1,100%,100%,0,0,1,.5 autocrop_components ,,,, a x r $iw,1,100%,100%,0,0,$shift_var,.5 endl done
a y
f "s==2?[i0,i1<0?0:i1]:(s==3?[i0,i1,i2<0?0:i2]:s==4?[i0,i1,i2,i3<0?0:i3]:s==5?[i0,i1,i2,i3,i4<0?0:i4])"
fi
s c
f. i>$alpha_max?0:i
a c
EDIT: Looks like center positioning has issues with influence. Elsewhere, it works fine. Perhaps I may have to create dynamic row/column on the two side to take into consideration of positioning. That way, it’ll look balanced.