Guest User

Untitled

a guest
Jul 14th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #@gui Cubism: fx_jr_cubism_preview
  2. #@gui : sep = separator()
  3. #@gui : 0. Recompute = button()
  4. #@gui : 1. Threshold=float(2,0,15)
  5. #@gui : 2. Smoothness=float(1,0,500)
  6. #@gui : 3. Offset Amplitude=float(10,0,100)
  7. #@gui : 4. Anti-Aliasing=bool(1)
  8. fx_jr_cubism:
  9. repeat $! l[$>]
  10. ww={w}
  11. hh={h}
  12. aa=$4
  13. amp={$3*norm(w,h)*0.01}
  14. +b. $2 segment_watershed. $1
  15. f. ">begin(srand();rand=u(100,200));srand(i*rand);u"
  16. repeat {s}
  17. sh. $> *. {u(1,2)} rm.
  18. done
  19. to_gray.
  20. label.
  21. initsize={1+iM#1}
  22. $initsize,5,1,1
  23. vsize={$initsize*2}
  24. eval ${-math_lib}"
  25. coordinates_per_val=vector"$vsize"(0);
  26. count_per_val=vector"$initsize"(0);
  27. for(px=0,px<w#1,px++,
  28. for(py=0,py<h#1,py++,
  29. pos=i(#1,px,py);
  30. coordinates_per_val[pos*2]+=px;
  31. coordinates_per_val[pos*2+1]+=py;
  32. count_per_val[pos]++;
  33. );
  34. );
  35. for(n=0,n<"$initsize",n++,
  36. coordinates_per_val[n*2]/=count_per_val[n];
  37. coordinates_per_val[n*2+1]/=count_per_val[n];
  38. I(n,0)=coordinates_per_val[n*2];
  39. I(n,1)=coordinates_per_val[n*2+1];
  40. );
  41. "
  42. repeat {3}
  43. row={$>+2}
  44. sh. $row,$row,0,0 f. ">begin(randm=u(100+y,200+y);randa=u(1,3));srand((x+(randa))*randm);u"
  45. if {$>==2} n. 0,{2*pi} else n. 0,$amp fi
  46. rm.
  47. done
  48. $ww,$hh,1,2
  49. f. "val=vector2(0);
  50. I(#1)!=J(#1,1)?(val[0]+=1);
  51. I(#1)!=J(#1,0,1)?(val[1]+=1);
  52. I(#1)!=J(#1,-1)?(val[0]-=1);
  53. I(#1)!=J(#1,0,-1)?(val[1]-=1);
  54. val"
  55. *. 255
  56. +smooth. 10,0,1,1,5,15,0
  57. -.. .
  58. rm.
  59. /. 510
  60. f[0] "begin(const spec=s;
  61. cubism(id,xx,yy)=(
  62. params=crop(#2,id,0,0,0,1,5,1,1);
  63. xro=params[0];
  64. yro=params[1];
  65. xoff=params[2];
  66. yoff=params[3];
  67. ang=params[4];
  68. sang=sin(ang);
  69. cang=cos(ang);
  70. vx=xx-xro-xoff;
  71. vy=yy-yro-yoff;
  72. I(vx*cang+vy*sang+xoff+xro,vy*cang-vx*sang+yoff+yro,0,1,3)));
  73. xs=i(#-1,x,y,0,0);
  74. ys=i(#-1,x,y,0,1);
  75. ("$aa"&&xs!=0&&ys!=0)?(
  76. idlist=vector(#4,-1);
  77. freqlist=vector(#4,0);
  78. idnum=0;
  79. xdir=sign(xs);ydir=sign(ys);
  80. xo=abs(xs);yo=abs(ys);
  81. gridmult=[(1-xo)*(1-yo),xo*(1-yo),(1-xo)*yo,xo*yo];
  82. for(py=0,py<2,py++,
  83. for(px=0,px<2,px++,
  84. curr=i(#1,x+xdir*px,y+ydir*py,0,0,1);
  85. pos=find(idlist,curr);
  86. pos==-1?(idnum+=1;pos=find(idlist,-1);idlist[pos]=curr);
  87. freqlist[pos]+=gridmult[py*2+px];
  88. );
  89. );
  90. val=vector(#spec,0);
  91. for(n=0,n<idnum,n++,
  92. val+=cubism(idlist[n],x,y)*freqlist[n]);
  93. val):(cubism(i(#1,x,y,0,0,1),x,y))
  94. "
  95. rm[^0]
  96. endl done
  97. fx_jr_cubism_preview:
  98. fx_jr_cubism ${2-5}
Add Comment
Please, Sign In to add comment