Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #@cli spherize : _radius[%]>=0,_strength,_smoothness[%]>=0,_center_x[%],_center_y[%],_interpolation
- #@cli : Apply spherize effect on selected images.
- #@cli : Default values: 'radius=50%', 'strength=1', 'smoothness=0', 'center_x=center_y=50%' and 'interpolation=1'.
- #@cli : $ image.jpg -grid 5%,5%,0,0,0.6,255 --spherize ,
- spherize : -check "${1=50%}>=0 && ${3=0}>=0 && isint(${6=1}) && $6>=0 && $6<=2 && isint(${7=1}) && $7>=0 && $7<=3" -skip "${2=1},${4=50%},${5=50%}"
- -e[^-1] "Apply spherize effect on image$?, with radius $1, strength $2, smoothness $3, center ($4,$5) and "${"-arg 1+$6,nearest-neighbor,linear,cubic"}" interpolation."
- -if {!$1||!$2} -return -endif
- -v - -repeat $! -l[$>]
- rmax={${"-is_percent $1"}?0.5*sqrt((w-1)^2+(h-1)^2)*$1:$1}
- centerx={${"-is_percent $4"}?(w-1)*$4:$4}
- centery={${"-is_percent $5"}?(h-1)*$5:$5}
- strength={$2>0?$2:1-exp($2/5)}
- 100%,100%,1,2,"
- init(
- center = [ "$centerx","$centery" ];
- wh1 = [ w,h ] - 1;
- m2wh1 = 0.5*max(wh1);
- rmax = "$rmax"/m2wh1;
- const f = 1/"$strength";
- );
- xy = ([x,y] - center)/m2wh1;
- r = norm2(xy);
- z = r<rmax?sign($2)*sqrt(rmax^2 - r^2):0;
- xy = center + f*xy/(f + z)*m2wh1"
- -b. $3
- -warp.. .,0,$6,1 -rm.
- -endl -done -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement