View Single Post
Old 12-19-2018, 09:01 PM   #24
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 99
Default

Caution: some big gifs in this post

Quote:
Originally Posted by Eliseat View Post
Only thing left is wavy distortion.
I gave it a try Eli and it wasn't actually that hard

PHP Code:
// wave morph
// v0.1

//@param1:type 'function (see code)' 0 0 4 2 1 // 0=sine 1=square 2=saw 3=reverse saw 4=triangle
//@param2:amt_n 'amount' 0.1 0 1 0.5
//@param3:ph 'phase' 0 0 1 0.5

//@param6:nPer 'n half-periods' 2 1 100 50 1
//@param7:vert '0=horz 1=vert' 0 0 1 0.5 1
//@param8:bbx 'bounding box' 0 -1 1 0 1


in=0;
amt=(vert?project_w:project_h)*amt_n/2;

input_info(in,inW=project_w,inH=project_h);


bbx==? (
  
vert ? (
    
dstH=inH;
    
dstW=inW-2*amt;
  ):(
    
dstH=inH-2*amt;
    
dstW=inW;
  );
  
offs=amt;
):
bbx==-? (
  
vert ? (
    
dstH=inH;
    
dstW=inW+2*amt;
  ):(
    
dstH=inH+2*amt;
    
dstW=inW;
  );
  
offs=-amt;
):(
  
dstH=inH;
  
dstW=inW;
  
offs=0;
);
project_w=dstW;
project_h=dstH;

gfx_set(0,0,0,1);
gfx_fillrect(0,0,dstW,dstH);

i=0;
len=vert?inH:inW;
div=2*len/nPer;
while(
i<len) (
  
i_n=((i+ph*div)%div)/div;
  
fun=type==sin(i_n*2*$pi)
     :
type==i_n<0.5?-1:1
     
:type==? -1+2*i_n
     
:type==1-2*i_n
     
:type==i_n<0.5?-1+4*i_n:3-4*i_n;
  
fun=fun*amt-offs;
  
vert ?
    
gfx_blit(in,0fun,i,inW,10,i,inW,1)
    :
    
gfx_blit(in,0i,fun,1,inHi,0,1,inH);
  
i+=1;
); 
You can also make other funny things with it, e.g. enhance a static image of water:

Last edited by wwwmaze; 12-19-2018 at 09:07 PM.
wwwmaze is offline   Reply With Quote