Guest User

Morph Shape

a guest
Jul 27th, 2026
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | Science | 0 0
  1. #!/usr/bin/env gmic
  2. # File : morphshape.gmic
  3. # Author : David Tschumperle
  4.  
  5. # Entrypoint when run from CLI:
  6. go =>[^] "Morph Shape" e[] "" animate 30
  7.  
  8. # Main function
  9. go :
  10.   v 0
  11.  
  12.   shape_cupid 500 # Source shape
  13.   shape_dragonfly 500 # Target shape
  14.   ge 50% r 512,512,1,1,0,0,0.5,0.5
  15.  
  16.   # Extract contour parameterizations of largest components.
  17.   foreach { edgels -1 k[{argmax(${"-lof h"})}] channels. 0,1 f. "I==J[-1]?[-1,-1]:I" discard. -1 r. 1,50%,1,2,-1 }
  18.   r 1,${-max_h},1,2,1 1,32,1,1,y%4 r. 1,{-2,h} a[-3,-2] .,c rm.
  19.   => source,target
  20.   512,512,1,3,"lerp([0,64,0],[0,32,128],y/h)" => background
  21.   (0^0^0^0,255^255^255^255,255^0^0^255,255^128^0^255,255^255^0^255) => colormap
  22.  
  23.   # Perform curve interpolation.
  24.   repeat 50 {
  25.     k:=cut(lerp(-0.15,1.15,$%),0,1)
  26.     [source] sh. 0,1 b. y,{lerp(0,100,$k)},2 rm.
  27.     [target] sh. 0,1 b. y,{lerp(100,0,$k)},2 rm.
  28.     j.. .,0,0,0,0,$k rm.
  29.     {background,[w,h]} eval.. "pP = J[-1,2]; polygon(#-1,2,pP[0],pP[1],i0,i1,1,i2 + 1)"
  30.     dilate. 3 map. [colormap] +ja[background] .
  31.     rm[-3,-2]
  32.   }
  33.   rm[source,target,background,colormap]
  34.   +rv
  35.  
  36. # End of file.
  37.  
Tags: gmic
Advertisement
Add Comment
Please, Sign In to add comment