New math function 'wave()'

Here’s that:

$ gmic run '2000,1,1,1,10*wave((2+0.01*x)*x/w) plot.'
  1. Frequency is a function in x/w increasing in “time” as x \Rightarrow w : A basic siren whoop.
  2. One can push this pea only so far. Up the frequency and sampling breaks down.

The right hand raggedness stems from some brew of the plotting image itself not sampling the curve sufficiently and the underlying curve generator not having sufficient “time” resolution. Either way, one has to take care.

Lunchtime break over.

2 Likes

Stealing a lot from @grosgood, this is all i can do (spent more time searching for a command that accepts an image as argument haha!):

 gmic run 'sp apples 100%,100%,1,3,"100*wave((2*0.1)*x)*x/w" rotate. 90 r. ..,..  +displacement.. .,1,0,3 n. 0,255 +blend[0,-1] xor +plot... , d'


gmic run 'sp apples 100%,100%,1,3,"10*wave((2*0.01)*u)*y/h" +displacement.. .,1,0,3 n. 0,255 +blend[0,-1] or +plot... , d'
``
2 Likes

Looks like a new artistic filter is coming, @prawnsushi.

*Looks at screenshots*
*Looks at @Reptorian*
*Looks at the sky*
*Shrugs*
*Looks at the ground*
*Walks away*

in between losing a few card games to my son, i managed to write what is probably the worst warp effect ever using wave:

badwarp:
to_rgb
100%,100%,1,3,"a=$1;b=$2;c=$3;d=$4;n=$5;n*wave(w/x*a,wave(x/y*b,-x))+wave(h/y*c,wave(y/x*d,-y))" 
replace_nan. 0 # yeah someone put this terror in me
+rotate. 180 blend[-1,-2] multiply 
b. $6  n 0,255 +warp[0] [1],1,2,3  
keep.
3 Likes

You’re learning JIT coding. Keep it up. Then, you can make complex C++ like code.

argcheck
I don’t think your use of the second parameter to wave() is doing quite what you want or expect. After post 14 @David_Tschumperle changed the argument list, reducing it to two. In the new scheme, the second parameter c just selects curve type.

If, instead of c \in \{0,1,2,3\} , some other number is in place, the sine curve is the default. So, I don’t think much magic is being added by the highlighted bits; they compute some number; wave() likely takes that to be an overly prolix way to select the sine wave template. Examples prior to post 14 probably need to be reworked.

I have no idea what it does anyway!
I’ll try without later but i doubt it’ll be the same…
:blush:

Ok, so now i wonder how i can get the output i got on the left with my terrible command, without using said terrible command lol.

For a,b,c,d=-.4,10,.5,10 :

left:
100%,100%,1,3,"a=$1;b=$2;c=$3;d=$4;wave(w/x*a,wave(x/y*b,-x))+wave(h/y*c,wave(y/x*d,-y))"

right:
100%,100%,1,3,"a=$1;b=$2;c=$3;d=$4;wave(w/x*a,b)+wave(h/y*c,d)"

1 Like

For some random reason i randomly got very close today… Still some differences but close enough. Did i mention it was random? That’s so strange.

badwarp:
to_rgb
100%,100%,1,3,"a=$1;b=$2;c=$3;d=$4;wave(w/(x*a),wave(x/(y*b),-x))+wave(h/(y*c),wave(y/(x*d),-y))" 
100%,100%,1,3,"a=$1;b=$2;c=$3;d=$4;wave(w/(x*a%y),1)+wave(h/(y*c%x),1)" 
replace_nan 0 
+rotate[-1,-2] 180 blend[-1,-3] multiply  blend[-1,1] multiply 
n 0,255 
+warp[0] [1],1,2,3 
+warp[0] [2],1,2,3 
keep.

Didn’t use b and d the 2nd time though.

gmic ./badwarp.gmic run 'sp ,  badwarp 4,10,5,10  n 0,255 append_tiles[1,3,2,4] 2,2  equalize d'


1 Like