Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #@cli quiver : [function_image],_sampling[%]>0,_factor>=0,_is_arrow={ 0 | 1 },_opacity,_color1,...
- #@cli : Draw specified 2d vector/orientation field on selected images.
- #@cli : Default values: 'sampling=5%', 'factor=1', 'is_arrow=1', 'opacity=1', 'pattern=(undefined)'
- #@cli : and 'color1=0'.
- #@cli : $ 100,100,1,2,'if(c==0,x-w/2,y-h/2)' 500,500,1,3,255 -quiver[-1] [-2],10
- #@cli : $ image.jpg --resize2dy 600 -luminance[0] -gradient[0] -mul[1] -1 -reverse[0,1] -append[0,1] c -blur[0] 8 -orientation[0] -quiver[1] [0],20,1,1,0.8,255
- quiver : -check ${"-is_image_arg $1"}" && ${2=5%}>0 && ${3=1}>=0 && isbool(${4=1})" -skip "${5=1},${6=0}"
- -e[^-1] "Draw 2d vector field $1 on image$?, with sampling $2, factor $3, arrows "${"-arg 1+$4,disabled,enabled"}", opacity $5 and color (${6--1})."
- -v - -pass$1 -repeat {$!-1} -l[$>,-1]
- -eval ${-math_lib}"
- s_sampling = ['$2'];
- sampling = s_sampling[size(s_sampling) - 1 ]==_'%'?min(w#0,h#0)*$2:$2;
- vmax = max(abs(im),abs(iM));
- vmax = vmax?vmax:1;
- fact = $3*sampling/vmax;
- for (y = sampling/2, y<h#0, y+=sampling,
- for (x = sampling/2, x<w#0, x+=sampling,
- X = round(x*w/w#0); Y = round(y*h/h#0);
- u = i(X,Y,0,0)*fact; v = i(X,Y,0,1)*fact;
- if ($4,
- draw_arrow(#0,[x,y],[x + u,y + v],45,sampling/4,$5,[${6--1}]),
- draw_line(#0,[x - 0.5*u,y - 0.5*v],[x + 0.5*u,y + 0.5*v],$5,[${6--1}]);
- );
- );
- );
- "
- -endl -done -rm. -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement