├── 3D相关 ├── 与b站一同更新 ├── 函数库 │ ├── b站BV1zK4y1Q76i │ │ └── space.lua │ ├── 与b站一同更新 │ └── 啊 │ │ ├── space.lua │ │ └── 做视频的时候修复了一些小错误 └── 字幕 │ ├── bv号1xK4y1o7eM │ ├── 去除凸多面体的不可见面.ass │ └── 菱形十二面体.ass │ ├── b站BV1Qp4y1H73Z │ ├── 表面附着旋转绘图.ass │ ├── 表面附着绘图.ass │ └── 钻石绕其中心轴旋转.ass │ ├── b站BV1zK4y1Q76i │ ├── 动态生成函数.ass │ └── 建模函数的第一个返回值.ass │ ├── 与b站一同更新 │ └── 劈里啪啦 │ ├── b站同步更新? │ ├── 凸多面体带顶点亮星变形.ass │ ├── 动态来回截半立方体.ass │ ├── 同类模型间转变函数.ass │ └── 组合多面体动态渲染函数.ass ├── README.md ├── flex ├── 不归类函数 │ ├── Exkit.lua │ └── 诸如字幕 │ │ ├── 匀速n阶贝塞尔曲线(精准快速) │ │ ├── 切线效果.ass │ │ ├── 匀速贝塞尔曲线 函数测速.ass │ │ ├── 匀速贝塞尔曲线.ass │ │ ├── 获取贝塞尔曲线在pct处的点的坐标.ass │ │ └── 贝塞尔曲线自定义加速度.ass │ │ ├── 匀速化一般参数曲线(精准快速) │ │ ├── 切线效果.ass │ │ ├── 匀速化非周期参数曲线(不人为传入导数).ass │ │ ├── 参数曲线自定义加速度.ass │ │ ├── 振荡曲线迅速匀速化(也可不人为提供导数).ass │ │ └── 获取弧长参数为pct时,曲线上点的坐标.ass │ │ ├── 各种不归类的函数以及以往的函数库都有可能整合在Exkit里.txt │ │ └── 超高精度数值积分 │ │ ├── 其它说明.txt │ │ ├── 高精度数值积分 例一.ass │ │ └── 高精度数值积分 例二.ass ├── 分形噪声 │ ├── noise初.lua │ ├── 以后会更新该库,但b站更新才会更 │ └── 更新 │ │ ├── noise.lua │ │ └── 字幕 │ │ ├── 二维柏林噪声.ass │ │ ├── 卡通效果 │ │ ├── 卡通动漫火线.ass │ │ └── 卡通火焰.ass │ │ ├── 平面噪声 │ │ ├── 值噪声.ass │ │ ├── 分形噪声.ass │ │ └── 块状噪声.ass │ │ └── 随机曲线 │ │ ├── 随机曲线(粒子).ass │ │ └── 随机曲线.ass ├── 和b站同步更新 └── 物理引擎 │ └── 物理模拟效果.ass ├── 多边形库 ├── ployc优化更新版 │ ├── polyc.lua │ └── 一万个点只要0.7秒钟.ass ├── polyc.lua └── 布尔运算 │ ├── Yutils.lua │ ├── polyb.lua │ └── polyc.dll ├── 转载请注明作者和出处!.txt └── 音频频谱 ├── Thank you, my twilight.mp3 ├── Yutils.lua ├── b站视频BV1C44y1B7CJ ├── ヒーロー supercell.mp3 ├── 二胡.wav ├── 任意路径频谱.zip ├── 圆柱频谱.7z └── 环形频谱.ass /3D相关/与b站一同更新: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /3D相关/函数库/与b站一同更新: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /3D相关/函数库/啊/做视频的时候修复了一些小错误: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /3D相关/字幕/b站BV1zK4y1Q76i/建模函数的第一个返回值.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:23.976000:400000:1920:1080:47:163:254:c 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.375000 17 | Active Line: 4 18 | 19 | [V4+ Styles] 20 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 21 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0.5,0,2,10,10,10,1 22 | Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,1 23 | 24 | [Events] 25 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 26 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,c={"&HFFFFFF&","&HFFFF00&","&H6F70FF&","&H53C4FF&","&H66FF5B&","&HC7CCFF&"} 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,s=_G.space.cube(233,{23,66,88,-55,1111-623},{"y","z","x","x","y","y"},1,0,0,0,c) 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,s1=_G.space.cube(233,{333},{ {0.57735026918963,0.57735026918963,0.57735026918963} },1,0,0,0,c) 29 | Comment: 0,0:00:05.00,0:00:10.00,Default,静态cube,0,0,0,template line,!gloop(#s)!!relayer(s[j].lay)!{\p1\an7\pos(333,500)\c!s[j].c!}!s[j].s! 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,绕任意轴 ( 静态 ),0,0,0,template line,!gloop(#s1)!!relayer(s1[j].lay)!{\p1\an7\pos(960,500)\c!s1[j].c!}!s1[j].s! 31 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 32 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&HCFCFCF&}m 178.1 90.7 l 148.3 -123.2 l -23.4 -43.7 l 6.4 170.2 33 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&HB2B200&}m 6.4 170.2 l -23.4 -43.7 l -178.1 -90.7 l -148.3 123.2 34 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&H3C3D8B&}m -23.4 -43.7 l 148.3 -123.2 l -6.4 -170.2 l -178.1 -90.7 35 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&H3A89B2&}m 148.3 -123.2 l 178.1 90.7 l 23.4 43.7 l -6.4 -170.2 36 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&H388B32&}m 178.1 90.7 l 6.4 170.2 l -148.3 123.2 l 23.4 43.7 37 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(333,500)\c&HA2A6CF&}m 23.4 43.7 l -6.4 -170.2 l -178.1 -90.7 l -148.3 123.2 38 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&HFFFFFF&}m -116.5 -116.5 l 99.6 -169.1 l 169.1 47 l -47 99.6 39 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&H717100&}m -47 99.6 l 169.1 47 l 116.5 116.5 l -99.6 169.1 40 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&H37377E&}m 169.1 47 l 99.6 -169.1 l 47 -99.6 l 116.5 116.5 41 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&H255771&}m 99.6 -169.1 l -116.5 -116.5 l -169.1 -47 l 47 -99.6 42 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&H327E2D&}m -116.5 -116.5 l -47 99.6 l -99.6 169.1 l -169.1 -47 43 | Dialogue: 1,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(960,500)\c&HC7CCFF&}m -169.1 -47 l 47 -99.6 l 116.5 116.5 l -99.6 169.1 44 | -------------------------------------------------------------------------------- /3D相关/字幕/与b站一同更新: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /3D相关/字幕/劈里啪啦/b站同步更新?: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StupidAss 2 | 3 | #### 分享一些自己瞎写的函数库和字幕 4 | 5 | #### https://space.bilibili.com/346816900/channel/seriesdetail?sid=231885 6 | **一般来说是和b站一同更新,所以b站未更新该仓库就应该不会更新** 7 | 8 | 可能会发布更多函数库 9 | 10 | 11 | #### 嗯 12 | 13 | 修复了番茄鸡蛋不加葱的问题 14 | 15 | 修复了水煮肉片不加辣椒的问题 16 | 17 | 修复了无法使用的问题 18 | 19 | 修复了无法不使用的问题 20 | 21 | 修复了无法使用不使用的问题 22 | 23 | 24 | #### 起源? 25 | 26 | 27 | 千与千寻、未麻的部屋、红辣椒、千年女优、妄想代理人、东京教父、恶童、死亡代理人、人狼 28 | -------------------------------------------------------------------------------- /flex/不归类函数/Exkit.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | --我又瞎写了个破烂函数库 4 | --我b站账号:https://space.bilibili.com/346816900 5 | --Aegisub视频整合:https://space.bilibili.com/346816900/channel/seriesdetail?sid=231885 6 | --转载请注明作者和出处! 7 | 8 | 9 | local Exkit={} 10 | 11 | function Exkit.derivative_1st(f,x,eps) 12 | local eps=eps or 1e-10 local delta,n=math.min(eps^0.5,1e-3),7 13 | local maxErr,h=math.max(50*eps,1e-3),2^n*1e-6 14 | local h2,r,err=2*h,{0},delta/2 15 | for i=1,n do 16 | local x1=x-h local x2,d,r1=x1+h2,1,r[1] 17 | r[i]=(f(x2)-f(x1))/h2 local k=i-1 18 | while k>0 do 19 | d=d*4 r[k]=r[k+1]+(r[k+1]-r[k])/(d-1) k=k-1 20 | end 21 | if i>=2 then 22 | err=math.abs(r[1])<=delta and math.abs(r[1]-r1) or math.abs((r[1]-r1)/r[1]) 23 | if errmaxErr and false or r[1] 28 | return slope 29 | end 30 | 31 | local function e_sinh(f,a,eps,d) 32 | local ev,h2=2,f(a+d/2)-f(a+d*2)*4 local i,j=1,32 33 | if h2-math.huge and math.abs(h2)>1e-5 then 34 | local r,fl,fr,h,s=0,0,0,0,0 local lfl,lfr,lr=0,0,2 35 | repeat 36 | j=j/2 r=2^(i+j) fl=f(a+d/r) fr=f(a+d*r)*r*r ev=ev+2 h=fl-fr 37 | until (j<=1 or (h-math.huge)) 38 | if j>1 and h-math.huge and Exkit.sgn(h)~=Exkit.sgn(h2) then 39 | lfl=fl lfr=fr 40 | repeat 41 | j=j/2 r=2^(i+j) fl=f(a+d/r) fr=f(a+d*r)*r*r ev=ev+2 h=fl-fr 42 | if h-math.huge then 43 | s=s+math.abs(h) 44 | if Exkit.sgn(h)==Exkit.sgn(h2) then 45 | i=i+j 46 | else lfl=fl lfr=fr lr=r 47 | end 48 | end 49 | until (j<=1) 50 | if s>eps then 51 | h=lfl-lfr r=lr 52 | if h~=0 then r=r/2 end 53 | if math.abs(lfl)b then a,b=b,a sign=-1 end 68 | if a-math.huge and b-math.huge then 69 | c=(a+b)/2 d=(b-a)/2 v=c 70 | elseif a-math.huge then 71 | mode=1 d=e_sinh(f,a,eps,d) c=a v=a+d 72 | elseif b-math.huge then 73 | mode=1 d=e_sinh(f,b,eps,-d) sign=-sign c=b v=b+d 74 | else mode=2 v=0 75 | end 76 | s=f(v) 77 | repeat 78 | local q,p,fp,fm,t,eh=0,0,0,0,0,0 79 | h=h/2 t=math.exp(h) eh=k>0 and t*t or t 80 | if mode==0 then 81 | repeat 82 | local u=math.exp(1/t-t) local r=2*u/(1+u) 83 | local w=(t+1/t)*r/(1+u) local x=d*r 84 | if a+x>a then 85 | local y=f(a+x) 86 | if y-math.huge then fp=y end 87 | end 88 | if b-x-math.huge then fm=y end 91 | end 92 | q=w*(fp+fm) p=p+q t=t*eh 93 | until (math.abs(q)<=eps*math.abs(p)) 94 | else 95 | t=t/2 96 | repeat 97 | local r=math.exp(t-.25/t) local x,y,w,q=0,0,r,0 98 | if mode==1 then 99 | x=c+d/r if x==c then break end y=f(x) 100 | if y-math.huge then q=q+y/w end 101 | else 102 | r=(r-1/r)/2 w=(w+1/w)/2 x=c-d*r y=f(x) 103 | if y-math.huge then q=q+y*w end 104 | end 105 | x=c+d*r y=f(x) 106 | if y-math.huge then q=q+y*w end 107 | q=q*(t+.25/t) p=p+q t=t*eh 108 | until (math.abs(q)<=eps*math.abs(p)) 109 | end 110 | v=s-p s=s+p k=k+1 111 | until (math.abs(v)<=tol*math.abs(s) or k>n) 112 | return sign*d*s*h,math.abs(v)/(math.abs(s)+eps) 113 | end 114 | 115 | function Exkit.modAB(f,x1,x2,eps) 116 | local y1,y2,bi=f(x1),f(x2),true local cnt,eps=0,eps or 1e-14 117 | local x0,side,n=x1,0,-math.floor(math.log(eps,2)/2)+1 118 | for i=1,n do 119 | local x3,y3 cnt=cnt+1 120 | if bi then 121 | x3=(x1+x2)/2 y3=f(x3) local ym=(y1+y2)/2 122 | if math.abs(ym-y3)<0.25*(math.abs(ym)+math.abs(y3)) then 123 | bi=false 124 | end 125 | else x3=(x1*y2-y1*x2)/(y2-y1) y3=f(x3) 126 | end 127 | if math.abs(y3)<=eps and math.abs(x3-x0)<=eps then 128 | return x3,cnt 129 | end 130 | x0=x3 131 | if side==1 then 132 | local m=1-y3/y1 if m<=0 then y2=y2/2 else y2=y2*m end 133 | elseif side==2 then 134 | local m=1-y3/y2 if m<=0 then y1=y1/2 else y1=y1*m end 135 | end 136 | if Exkit.sgn(y1)==Exkit.sgn(y3) then 137 | if not bi then side=1 end x1=x3 y1=y3 138 | else 139 | if not bi then side=2 end x2=x3 y2=y3 140 | end 141 | if i%n==0 then bi=true side=0 end 142 | end 143 | return x0,cnt 144 | end 145 | 146 | function Exkit.curve_length_robust(x,y,t1,t2,eps,x1,y1)--超高精度数值积分,但是龟速,并无卵用 147 | local eps=eps or 1e-14 148 | local function func(t) 149 | local vx,vy=x1 and x1(t) or Exkit.derivative_1st(x,t),y1 and y1(t) or Exkit.derivative_1st(y,t) 150 | return (vx^2+vy^2)^0.5 151 | end 152 | return Exkit.integrator(func,t1,t2,eps) 153 | end 154 | 155 | function Exkit.curve_t_at_s_robust(x,y,t1,t2,s,L,x1,y1)--超高精度数值积分,但是龟速,并无卵用 156 | local arc_len=s*L 157 | local function func(u) 158 | return Exkit.curve_length_robust(x,y,t1,t1+u,1e-14,x1,y1)-arc_len 159 | end 160 | return Exkit.modAB(func,0,t2-t1,1e-5) 161 | end 162 | 163 | function Exkit.Mround2(num)--个人最常用的,保留两位小数 164 | return math.floor(num*100+.5)/100 165 | end 166 | 167 | function Exkit.Mround1(num) return math.floor(num*10+.5)/10 end 168 | 169 | function Exkit.Mround3(num) return math.floor(num*1000+.5)/1000 end 170 | 171 | function Exkit.curve_to_px_robust(x,y,t1,t2,ds,accel,x1,y1,L)--超高精度数值积分,但是龟速,并无卵用 172 | local L,accel=L or Exkit.curve_length_robust(x,y,t1,t2,1e-14,x1,y1),accel or 1 173 | local ds=ds or 1 local n,px=math.ceil(L/ds),{} 174 | for i=1,n do 175 | local a=type(accel)=='function' and accel(i,n) or accel 176 | local s=(i-1)/(n-1) local t=t1+Exkit.curve_t_at_s_robust(x,y,t1,t2,s^a,L,x1,y1) 177 | local vx,vy=x1 and x1(t) or Exkit.derivative_1st(x,t),y1 and y1(t) or Exkit.derivative_1st(y,t) 178 | local angle=-math.deg(math.atan2(vy,vx)) local pt_x,pt_y=x(t),y(t) 179 | px[i]={x=Exkit.Mround2(pt_x),y=Exkit.Mround2(pt_y),angle=Exkit.Mround2(angle)} 180 | end 181 | return px 182 | end 183 | 184 | Exkit.ABSCISSAS_K21={ 185 | -0.995657163025808081, 186 | -0.97390652851717172, 187 | -0.930157491355708226, 188 | -0.865063366688984511, 189 | -0.780817726586416897, 190 | -0.679409568299024406, 191 | -0.562757134668604683, 192 | -0.433395394129247191, 193 | -0.294392862701460198, 194 | -0.148874338981631211, 195 | 0, 196 | 0.148874338981631211, 197 | 0.294392862701460198, 198 | 0.433395394129247191, 199 | 0.562757134668604683, 200 | 0.679409568299024406, 201 | 0.780817726586416897, 202 | 0.865063366688984511, 203 | 0.930157491355708226, 204 | 0.97390652851717172, 205 | 0.995657163025808081 206 | } 207 | Exkit.WEIGHTS_K21={ 208 | 0.011694638867371874, 209 | 0.032558162307964727, 210 | 0.054755896574351996, 211 | 0.075039674810919953, 212 | 0.093125454583697606, 213 | 0.109387158802297642, 214 | 0.123491976262065851, 215 | 0.134709217311473326, 216 | 0.142775938577060081, 217 | 0.14773910490133849, 218 | 0.149445554002916906, 219 | 0.14773910490133849, 220 | 0.142775938577060081, 221 | 0.134709217311473326, 222 | 0.123491976262065851, 223 | 0.109387158802297642, 224 | 0.093125454583697606, 225 | 0.075039674810919953, 226 | 0.054755896574351996, 227 | 0.032558162307964727, 228 | 0.011694638867371874 229 | } 230 | Exkit.WEIGHTS_G10={ 231 | 0, 232 | 0.066671344308688138, 233 | 0, 234 | 0.149451349150580593, 235 | 0, 236 | 0.219086362515982044, 237 | 0, 238 | 0.269266719309996355, 239 | 0, 240 | 0.29552422471475287, 241 | 0, 242 | 0.29552422471475287, 243 | 0, 244 | 0.269266719309996355, 245 | 0, 246 | 0.219086362515982044, 247 | 0, 248 | 0.149451349150580593, 249 | 0, 250 | 0.066671344308688138, 251 | 0 252 | } 253 | 254 | function Exkit.gauss_kronrod(f,a,b) 255 | local dx,integral=(b-a)/2,0 256 | for i=1,#Exkit.ABSCISSAS_K21 do 257 | integral=integral+f(a+(Exkit.ABSCISSAS_K21[i]+1)*dx)*Exkit.WEIGHTS_K21[i] 258 | end 259 | return integral*dx 260 | end 261 | 262 | function Exkit.gauss_kronrod_integrate(f,a,b) 263 | local dx,integral,err=(b-a)/2,0,0 264 | for i=1,#Exkit.ABSCISSAS_K21 do 265 | local val=f(a+(Exkit.ABSCISSAS_K21[i]+1)*dx) 266 | integral=integral+val*Exkit.WEIGHTS_K21[i] 267 | err=err+val*Exkit.WEIGHTS_G10[i] 268 | end 269 | err=math.abs(dx)*(200*math.abs(err-integral))^1.5 270 | return integral*dx,err 271 | end 272 | 273 | function Exkit.gauss_kronrod_adaptive(f,a,b,n,tol)--自适应Gauss-Kronrod积分 274 | local quad,err=Exkit.gauss_kronrod_integrate(f,a,b) 275 | local n,tol,parts=n or 10,tol or 1e-12,{{q=quad,err=err,l=0,r=b}} 276 | for len=1,n do 277 | local err2,total,err_max,MAX=0,0,0,1 278 | for i=1,#parts do 279 | total=total+parts[i].q 280 | if parts[i].err>err_max then 281 | err_max=parts[i].err MAX=i 282 | end 283 | err2=err2+parts[i].err*parts[i].err 284 | end 285 | if math.abs(err2^0.5/total)L then 324 | else 325 | local s=(at_len-L0)/cnt[k] 326 | local t=t1+(k-1)*d+Exkit.curve_t_at_s(x,y,t1+(k-1)*d,t1+k*d,s,cnt[k],x1,y1) 327 | local vx,vy=x1 and x1(t) or Exkit.derivative_1st(x,t),y1 and y1(t) or Exkit.derivative_1st(y,t) 328 | local angle=-math.deg(math.atan2(vy,vx)) local pt_x,pt_y=x(t),y(t) 329 | px[#px+1]={x=Exkit.Mround2(pt_x),y=Exkit.Mround2(pt_y),angle=Exkit.Mround2(angle)} break 330 | end 331 | end 332 | end 333 | return px 334 | end 335 | 336 | function Exkit.curve_to_px_raw(x,y,t1,t2,N,x1,y1)--原速的参数曲线 337 | local px={} 338 | for i=1,N do 339 | local t=t1+(i-1)/(N-1)*(t2-t1) 340 | local vx,vy=x1 and x1(t) or Exkit.derivative_1st(x,t),y1 and y1(t) or Exkit.derivative_1st(y,t) 341 | local angle=-math.deg(math.atan2(vy,vx)) local pt_x,pt_y=x(t),y(t) 342 | px[#px+1]={x=Exkit.Mround2(pt_x),y=Exkit.Mround2(pt_y),angle=Exkit.Mround2(angle)} 343 | end 344 | return px 345 | end 346 | 347 | function Exkit.Bezier(x,y,t) 348 | local pos_x,pos_y,n=0,0,#x 349 | for i=1,n do 350 | pos_x=pos_x+x[i]*t^(i-1)*((1-t)^(n-i))*Exkit.combination(n-1,i-1) 351 | pos_y=pos_y+y[i]*t^(i-1)*((1-t)^(n-i))*Exkit.combination(n-1,i-1) 352 | end 353 | return pos_x,pos_y 354 | end 355 | 356 | function Exkit.Bezier_derivative_1st(x,y,t) 357 | local vx,vy,n=0,0,#x 358 | for i=1,n-1 do 359 | vx=vx+(x[i+1]-x[i])*t^(i-1)*((1-t)^(n-i-1))*Exkit.combination(n-2,i-1) 360 | vy=vy+(y[i+1]-y[i])*t^(i-1)*((1-t)^(n-i-1))*Exkit.combination(n-2,i-1) 361 | end 362 | return (n-1)*vx,(n-1)*vy 363 | end 364 | 365 | function Exkit.sgn(n) 366 | return n<0 and -1 or n>0 and 1 or 0 367 | end 368 | 369 | function Exkit.permutation(n,m) 370 | local p=1 for i=n,n-m+1,-1 do p=p*i end 371 | return p 372 | end 373 | 374 | function Exkit.combination(a,b) 375 | return Exkit.permutation(a,b)/Exkit.permutation(b,b) 376 | end 377 | 378 | function Exkit.Bezier_length(x,y,t1,t2) 379 | local function f(u) 380 | local vx,vy=Exkit.Bezier_derivative_1st(x,y,u) 381 | return (vx^2+vy^2)^0.5 382 | end 383 | return Exkit.gauss_kronrod(f,t1,t2) 384 | end 385 | 386 | function Exkit.Bezier_t_at_s(x,y,t1,t2,s,L) 387 | local arc_len=s*L 388 | local function f(u) 389 | return Exkit.Bezier_length(x,y,t1,t1+u)-arc_len 390 | end 391 | return Exkit.modAB(f,0,t2-t1,1e-5) 392 | end 393 | 394 | function Exkit.Bezier_to_px(x,y,ds,accel,n)--匀速n阶贝塞尔曲线(精准快速) 395 | local n,px,accel,ds=n or 8,{},accel or 1,ds or 1 396 | local d,cnt,len=1/n,{},0 397 | for i=1,n do 398 | local L=Exkit.Bezier_length(x,y,(i-1)*d,i*d) cnt[i]=L len=len+L 399 | end 400 | local N=math.ceil(len/ds) 401 | for i=1,N do 402 | local a=type(accel)=='function' and accel(i,N) or accel local at_len,L=len*((i-1)/(N-1))^a,0 403 | for k=1,n do 404 | local L0=L L=L+cnt[k] 405 | if at_len>L then 406 | else local s=(at_len-L0)/cnt[k] 407 | local t=(k-1)*d+Exkit.Bezier_t_at_s(x,y,(k-1)*d,k*d,s,cnt[k]) 408 | local vx,vy=Exkit.Bezier_derivative_1st(x,y,t) 409 | local angle=-math.deg(math.atan2(vy,vx)) local pt_x,pt_y=Exkit.Bezier(x,y,t) 410 | px[#px+1]={x=Exkit.Mround2(pt_x),y=Exkit.Mround2(pt_y),angle=Exkit.Mround2(angle)} break 411 | end 412 | end 413 | end 414 | return px 415 | end 416 | 417 | function Exkit.Bezier_to_px_raw(x,y,N)--原始速度的n阶贝塞尔曲线 418 | local px={} 419 | for i=1,N do 420 | local t=(i-1)/(N-1) local vx,vy=Exkit.Bezier_derivative_1st(x,y,t) 421 | local angle=-math.deg(math.atan2(vy,vx)) local pt_x,pt_y=Exkit.Bezier(x,y,t) 422 | px[#px+1]={x=Exkit.Mround2(pt_x),y=Exkit.Mround2(pt_y),angle=Exkit.Mround2(angle)} 423 | end 424 | return px 425 | end 426 | 427 | function Exkit.Bezier_length_at_t(x,y,t)--n阶贝塞尔曲线在t处的长度 428 | local function f(u) 429 | local vx,vy=Exkit.Bezier_derivative_1st(x,y,u) 430 | return (vx^2+vy^2)^0.5 431 | end 432 | local quad=0 433 | for i=1,16 do 434 | quad=quad+Exkit.gauss_kronrod(f,(i-1)*t*0.0625,i*t*0.0625) 435 | end 436 | return quad 437 | end 438 | 439 | function Exkit.smoothstep(t,s,e) 440 | if s==nil or e==nil then 441 | return 3*t^2-2*t^3 442 | else 443 | t=(t-s)/(e-s) t=t>1 and 1 or t<0 and 0 or t 444 | return 3*t^2-2*t^3 445 | end 446 | end 447 | 448 | 449 | 450 | 451 | 452 | 453 | _G.Exkit=Exkit 454 | 455 | return _G.Exkit 456 | 457 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/匀速n阶贝塞尔曲线(精准快速)/切线效果.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:60.000000:19000:1920:1080:0:0:0:c 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.500000 17 | Active Line: 4 18 | Video Position: 3 19 | 20 | [V4+ Styles] 21 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 22 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 23 | Style: Default,黑体,90,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1 24 | 25 | [Events] 26 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,Exkit = _G.require('Exkit') 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,px,py={},{} for i=1,20 do local x=(i-1)/20*666+1/20*666*math.random() local y=math.random(-150,150) px[i]=x py[i]=y end 29 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,s_time=_G.os.clock() xx = Exkit.Bezier_to_px( px , py , 10 ) dur=_G.os.clock()-s_time 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,!gloop(#xx)!{\p1\an7\pos(!xx[j].x+66 !,! xx[j].y+ 200 !)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 31 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,!gloop(#xx)!!retime('line',(j-1)/maxj*$ldur,j/maxj*$ldur-$ldur)!{\p1\an7\pos(!xx[j].x+66 !,! xx[j].y+ 200 !)\fsc150\frz!xx[j].angle!\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 32 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,耗时为 !dur! 33 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 34 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(88.963314558393,237)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 35 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(92.903421729791,227.67298425755)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 36 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(97.719505650374,218.76960548808)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 37 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(103.667443048,210.58449936301)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 38 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(110.91470743601,203.53058384389)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 39 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(119.34834340041,197.94847396849)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 40 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(128.60048987628,193.8522985394)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 41 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(138.31747042623,191.0175460002)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 42 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(148.28562767806,189.25073354021)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 43 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(158.37961513005,188.47218236878)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 44 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(168.50255208721,188.64283038301)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 45 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(178.57424893769,189.6819677777)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 46 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(188.54567924936,191.44531514942)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 47 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(198.40656936856,193.75157040031)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 48 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(208.17741109365,196.41574600928)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 49 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(217.8955317285,199.26719354038)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 50 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(227.60342973835,202.15341596489)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 51 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(237.34102392596,204.93737733661)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 52 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(247.14051995258,207.49398827357)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 53 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(257.02257033275,209.70873142483)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 54 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(266.99335191069,211.47978289011)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 55 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(277.04319993381,212.72382115863)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 56 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(287.14801623085,213.38427375033)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 57 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(297.27422823433,213.43914068676)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 58 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(307.38665587746,212.90485421886)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 59 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(317.45669942527,211.83395905764)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 60 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(327.46812229426,210.30724441985)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 61 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(337.41880702872,208.42321997641)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 62 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(347.31887214881,206.28803838142)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 63 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(357.18661601696,204.0075661504)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 64 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(367.04380081333,201.68171144392)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 65 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(376.91131742443,199.40022384167)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 66 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(386.80581374788,197.23906674519)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 67 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(396.73762983122,195.25683372337)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 68 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(406.71018938376,193.49125473198)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 69 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(416.72084585482,191.95633760962)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 70 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(426.762751432,190.64096073105)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 71 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(436.82712321565,189.50959576358)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 72 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(446.90505584587,188.50548219906)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 73 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(456.98833432982,187.55617924752)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 74 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(467.06914901625,186.58124031309)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 75 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(477.13923227095,185.5017001682)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 76 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(487.18939809507,184.25086567586)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 77 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(497.21045678536,182.78535599767)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 78 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(507.19600457286,181.09465926131)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 79 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(517.14635438709,179.20740077576)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 80 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(527.0719469308,177.19350063952)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 81 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(536.99416863072,175.16298994553)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 82 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(546.94202078955,173.26301378205)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 83 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(556.94364055739,171.67337072331)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 84 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(567.01260794217,170.59764512922)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 85 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(577.13150612239,170.24318960346)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 86 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(587.24112344081,170.7837968671)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 87 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(597.24893477351,172.3111055114)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 88 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(607.06248690121,174.79995087199)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 89 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(616.63111230136,178.11146809096)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 90 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(625.9712693344,182.02468134625)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 91 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(635.17085680523,186.260059527)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 92 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(644.38725803341,190.45820938005)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 93 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(653.84600920306,194.06540917877)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 94 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(663.75800138792,196.01138748956)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 95 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(673.65973262839,194.3668233449)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 96 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(681.72866905067,188.37890385493)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 97 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(687.38848360677,180.01132503645)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 98 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(691.38228161003,170.7134257849)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 99 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(694.28226761223,161.0134720983)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 100 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(696.39059442322,151.10962694589)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 101 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(697.85379522721,141.08956543697)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 102 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(698.71588875262,131)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 103 | Dialogue: 0,0:00:00.00,0:00:00.07,Default,,0,0,0,fx,{\p1\an7\pos(88.963314558393,237)\fsc150\frz69.293991242316\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 104 | Dialogue: 0,0:00:00.07,0:00:00.14,Default,,0,0,0,fx,{\p1\an7\pos(92.903421729791,227.67298425755)\fsc150\frz64.648807223892\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 105 | Dialogue: 0,0:00:00.14,0:00:00.21,Default,,0,0,0,fx,{\p1\an7\pos(97.719505650374,218.76960548808)\fsc150\frz58.177260151912\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 106 | Dialogue: 0,0:00:00.21,0:00:00.29,Default,,0,0,0,fx,{\p1\an7\pos(103.667443048,210.58449936301)\fsc150\frz49.425038741677\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 107 | Dialogue: 0,0:00:00.29,0:00:00.36,Default,,0,0,0,fx,{\p1\an7\pos(110.91470743601,203.53058384389)\fsc150\frz38.845326312878\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 108 | Dialogue: 0,0:00:00.36,0:00:00.43,Default,,0,0,0,fx,{\p1\an7\pos(119.34834340041,197.94847396849)\fsc150\frz28.3656738651\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 109 | Dialogue: 0,0:00:00.43,0:00:00.50,Default,,0,0,0,fx,{\p1\an7\pos(128.60048987628,193.8522985394)\fsc150\frz19.758143012851\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 110 | Dialogue: 0,0:00:00.50,0:00:00.58,Default,,0,0,0,fx,{\p1\an7\pos(138.31747042623,191.0175460002)\fsc150\frz13.004646431703\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 111 | Dialogue: 0,0:00:00.58,0:00:00.65,Default,,0,0,0,fx,{\p1\an7\pos(148.28562767806,189.25073354021)\fsc150\frz7.182078262037\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 112 | Dialogue: 0,0:00:00.65,0:00:00.72,Default,,0,0,0,fx,{\p1\an7\pos(158.37961513005,188.47218236878)\fsc150\frz1.6740043158875\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 113 | Dialogue: 0,0:00:00.72,0:00:00.79,Default,,0,0,0,fx,{\p1\an7\pos(168.50255208721,188.64283038301)\fsc150\frz-3.532464255103\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 114 | Dialogue: 0,0:00:00.79,0:00:00.87,Default,,0,0,0,fx,{\p1\an7\pos(178.57424893769,189.6819677777)\fsc150\frz-8.1149350841426\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 115 | Dialogue: 0,0:00:00.87,0:00:00.94,Default,,0,0,0,fx,{\p1\an7\pos(188.54567924936,191.44531514942)\fsc150\frz-11.771799825681\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 116 | Dialogue: 0,0:00:00.94,0:00:01.01,Default,,0,0,0,fx,{\p1\an7\pos(198.40656936856,193.75157040031)\fsc150\frz-14.37933938468\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 117 | Dialogue: 0,0:00:01.01,0:00:01.08,Default,,0,0,0,fx,{\p1\an7\pos(208.17741109365,196.41574600928)\fsc150\frz-15.959325126132\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 118 | Dialogue: 0,0:00:01.08,0:00:01.15,Default,,0,0,0,fx,{\p1\an7\pos(217.8955317285,199.26719354038)\fsc150\frz-16.596554126179\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 119 | Dialogue: 0,0:00:01.15,0:00:01.23,Default,,0,0,0,fx,{\p1\an7\pos(227.60342973835,202.15341596489)\fsc150\frz-16.384215269716\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 120 | Dialogue: 0,0:00:01.23,0:00:01.30,Default,,0,0,0,fx,{\p1\an7\pos(237.34102392596,204.93737733661)\fsc150\frz-15.404359531291\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 121 | Dialogue: 0,0:00:01.30,0:00:01.37,Default,,0,0,0,fx,{\p1\an7\pos(247.14051995258,207.49398827357)\fsc150\frz-13.730136683276\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 122 | Dialogue: 0,0:00:01.37,0:00:01.44,Default,,0,0,0,fx,{\p1\an7\pos(257.02257033275,209.70873142483)\fsc150\frz-11.438829924286\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 123 | Dialogue: 0,0:00:01.44,0:00:01.52,Default,,0,0,0,fx,{\p1\an7\pos(266.99335191069,211.47978289011)\fsc150\frz-8.6287340195351\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 124 | Dialogue: 0,0:00:01.52,0:00:01.59,Default,,0,0,0,fx,{\p1\an7\pos(277.04319993381,212.72382115863)\fsc150\frz-5.4335009105184\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 125 | Dialogue: 0,0:00:01.59,0:00:01.66,Default,,0,0,0,fx,{\p1\an7\pos(287.14801623085,213.38427375033)\fsc150\frz-2.0265960916149\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 126 | Dialogue: 0,0:00:01.66,0:00:01.73,Default,,0,0,0,fx,{\p1\an7\pos(297.27422823433,213.43914068676)\fsc150\frz1.3897969617357\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 127 | Dialogue: 0,0:00:01.73,0:00:01.81,Default,,0,0,0,fx,{\p1\an7\pos(307.38665587746,212.90485421886)\fsc150\frz4.6101559938568\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 128 | Dialogue: 0,0:00:01.81,0:00:01.88,Default,,0,0,0,fx,{\p1\an7\pos(317.45669942527,211.83395905764)\fsc150\frz7.4552461207656\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 129 | Dialogue: 0,0:00:01.88,0:00:01.95,Default,,0,0,0,fx,{\p1\an7\pos(327.46812229426,210.30724441985)\fsc150\frz9.793519714908\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 130 | Dialogue: 0,0:00:01.95,0:00:02.02,Default,,0,0,0,fx,{\p1\an7\pos(337.41880702872,208.42321997641)\fsc150\frz11.54804837604\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 131 | Dialogue: 0,0:00:02.02,0:00:02.10,Default,,0,0,0,fx,{\p1\an7\pos(347.31887214881,206.28803838142)\fsc150\frz12.691643245045\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 132 | Dialogue: 0,0:00:02.10,0:00:02.17,Default,,0,0,0,fx,{\p1\an7\pos(357.18661601696,204.0075661504)\fsc150\frz13.237108693741\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 133 | Dialogue: 0,0:00:02.17,0:00:02.24,Default,,0,0,0,fx,{\p1\an7\pos(367.04380081333,201.68171144392)\fsc150\frz13.228424761151\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 134 | Dialogue: 0,0:00:02.24,0:00:02.31,Default,,0,0,0,fx,{\p1\an7\pos(376.91131742443,199.40022384167)\fsc150\frz12.73527533538\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 135 | Dialogue: 0,0:00:02.31,0:00:02.39,Default,,0,0,0,fx,{\p1\an7\pos(386.80581374788,197.23906674519)\fsc150\frz11.850424001418\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 136 | Dialogue: 0,0:00:02.39,0:00:02.46,Default,,0,0,0,fx,{\p1\an7\pos(396.73762983122,195.25683372337)\fsc150\frz10.687837167276\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 137 | Dialogue: 0,0:00:02.46,0:00:02.53,Default,,0,0,0,fx,{\p1\an7\pos(406.71018938376,193.49125473198)\fsc150\frz9.3791288894157\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 138 | Dialogue: 0,0:00:02.53,0:00:02.60,Default,,0,0,0,fx,{\p1\an7\pos(416.72084585482,191.95633760962)\fsc150\frz8.0666653647232\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 139 | Dialogue: 0,0:00:02.60,0:00:02.68,Default,,0,0,0,fx,{\p1\an7\pos(426.762751432,190.64096073105)\fsc150\frz6.8931805410731\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 140 | Dialogue: 0,0:00:02.68,0:00:02.75,Default,,0,0,0,fx,{\p1\an7\pos(436.82712321565,189.50959576358)\fsc150\frz5.9891893078208\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 141 | Dialogue: 0,0:00:02.75,0:00:02.82,Default,,0,0,0,fx,{\p1\an7\pos(446.90505584587,188.50548219906)\fsc150\frz5.460024667853\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 142 | Dialogue: 0,0:00:02.82,0:00:02.89,Default,,0,0,0,fx,{\p1\an7\pos(456.98833432982,187.55617924752)\fsc150\frz5.3737308134499\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 143 | Dialogue: 0,0:00:02.89,0:00:02.97,Default,,0,0,0,fx,{\p1\an7\pos(467.06914901625,186.58124031309)\fsc150\frz5.750204629627\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 144 | Dialogue: 0,0:00:02.97,0:00:03.04,Default,,0,0,0,fx,{\p1\an7\pos(477.13923227095,185.5017001682)\fsc150\frz6.5520999999338\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 145 | Dialogue: 0,0:00:03.04,0:00:03.11,Default,,0,0,0,fx,{\p1\an7\pos(487.18939809507,184.25086567586)\fsc150\frz7.6795150732006\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 146 | Dialogue: 0,0:00:03.11,0:00:03.18,Default,,0,0,0,fx,{\p1\an7\pos(497.21045678536,182.78535599767)\fsc150\frz8.9720750638448\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 147 | Dialogue: 0,0:00:03.18,0:00:03.26,Default,,0,0,0,fx,{\p1\an7\pos(507.19600457286,181.09465926131)\fsc150\frz10.22123144425\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 148 | Dialogue: 0,0:00:03.26,0:00:03.33,Default,,0,0,0,fx,{\p1\an7\pos(517.14635438709,179.20740077576)\fsc150\frz11.191207732317\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 149 | Dialogue: 0,0:00:03.33,0:00:03.40,Default,,0,0,0,fx,{\p1\an7\pos(527.0719469308,177.19350063952)\fsc150\frz11.641953012762\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 150 | Dialogue: 0,0:00:03.40,0:00:03.47,Default,,0,0,0,fx,{\p1\an7\pos(536.99416863072,175.16298994553)\fsc150\frz11.347069332152\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 151 | Dialogue: 0,0:00:03.47,0:00:03.55,Default,,0,0,0,fx,{\p1\an7\pos(546.94202078955,173.26301378205)\fsc150\frz10.106260866274\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 152 | Dialogue: 0,0:00:03.55,0:00:03.62,Default,,0,0,0,fx,{\p1\an7\pos(556.94364055739,171.67337072331)\fsc150\frz7.7620392673266\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 153 | Dialogue: 0,0:00:03.62,0:00:03.69,Default,,0,0,0,fx,{\p1\an7\pos(567.01260794217,170.59764512922)\fsc150\frz4.2377429483527\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 154 | Dialogue: 0,0:00:03.69,0:00:03.76,Default,,0,0,0,fx,{\p1\an7\pos(577.13150612239,170.24318960346)\fsc150\frz-0.39223961599617\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 155 | Dialogue: 0,0:00:03.76,0:00:03.84,Default,,0,0,0,fx,{\p1\an7\pos(587.24112344081,170.7837968671)\fsc150\frz-5.8245781630526\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 156 | Dialogue: 0,0:00:03.84,0:00:03.91,Default,,0,0,0,fx,{\p1\an7\pos(597.24893477351,172.3111055114)\fsc150\frz-11.519432741355\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 157 | Dialogue: 0,0:00:03.91,0:00:03.98,Default,,0,0,0,fx,{\p1\an7\pos(607.06248690121,174.79995087199)\fsc150\frz-16.824244046129\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 158 | Dialogue: 0,0:00:03.98,0:00:04.05,Default,,0,0,0,fx,{\p1\an7\pos(616.63111230136,178.11146809096)\fsc150\frz-21.150645943885\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 159 | Dialogue: 0,0:00:04.05,0:00:04.13,Default,,0,0,0,fx,{\p1\an7\pos(625.9712693344,182.02468134625)\fsc150\frz-24.039513239769\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 160 | Dialogue: 0,0:00:04.13,0:00:04.20,Default,,0,0,0,fx,{\p1\an7\pos(635.17085680523,186.260059527)\fsc150\frz-25.040769570568\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 161 | Dialogue: 0,0:00:04.20,0:00:04.27,Default,,0,0,0,fx,{\p1\an7\pos(644.38725803341,190.45820938005)\fsc150\frz-23.399280064562\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 162 | Dialogue: 0,0:00:04.27,0:00:04.34,Default,,0,0,0,fx,{\p1\an7\pos(653.84600920306,194.06540917877)\fsc150\frz-17.378050997617\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 163 | Dialogue: 0,0:00:04.34,0:00:04.42,Default,,0,0,0,fx,{\p1\an7\pos(663.75800138792,196.01138748956)\fsc150\frz-2.9404412343948\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 164 | Dialogue: 0,0:00:04.42,0:00:04.49,Default,,0,0,0,fx,{\p1\an7\pos(673.65973262839,194.3668233449)\fsc150\frz23.309343196792\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 165 | Dialogue: 0,0:00:04.49,0:00:04.56,Default,,0,0,0,fx,{\p1\an7\pos(681.72866905067,188.37890385493)\fsc150\frz48.080693072644\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 166 | Dialogue: 0,0:00:04.56,0:00:04.63,Default,,0,0,0,fx,{\p1\an7\pos(687.38848360677,180.01132503645)\fsc150\frz62.335302656669\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 167 | Dialogue: 0,0:00:04.63,0:00:04.71,Default,,0,0,0,fx,{\p1\an7\pos(691.38228161003,170.7134257849)\fsc150\frz70.512261895528\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 168 | Dialogue: 0,0:00:04.71,0:00:04.78,Default,,0,0,0,fx,{\p1\an7\pos(694.28226761223,161.0134720983)\fsc150\frz75.886738322047\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 169 | Dialogue: 0,0:00:04.78,0:00:04.85,Default,,0,0,0,fx,{\p1\an7\pos(696.39059442322,151.10962694589)\fsc150\frz79.931145138235\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 170 | Dialogue: 0,0:00:04.85,0:00:04.92,Default,,0,0,0,fx,{\p1\an7\pos(697.85379522721,141.08956543697)\fsc150\frz83.4054897655\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 171 | Dialogue: 0,0:00:04.92,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(698.71588875262,131)\fsc150\frz86.87751980771\c&H1DFF00&}m -21 1 l 26 1 l 18 7 l 35 0 l 18 -7 l 26 -1 l -21 -1 l -25 -4 l -28 -4 l -23 0 l -28 4 l -25 4 m -29 -4 l -32 -4 l -27 0 l -32 4 l -29 4 l -24 0 m -33 -4 l -36 -4 l -31 0 l -36 4 l -33 4 l -28 0 172 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,耗时为 0.019000000000005 173 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/匀速n阶贝塞尔曲线(精准快速)/匀速贝塞尔曲线 函数测速.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:60.000000:19000:1920:1080:0:0:0:c 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.500000 17 | Active Line: 1 18 | 19 | [V4+ Styles] 20 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 21 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 22 | Style: Default,黑体,90,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1 23 | 24 | [Events] 25 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 26 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,Exkit = _G.require('Exkit') 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,px,py={},{} for i=1,20 do local x=(i-1)/20*666+1/20*666*math.random() local y=math.random(-150,150) px[i]=x py[i]=y end 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,s_time=_G.os.clock() xx = Exkit.Bezier_to_px( px , py , 10 ) dur=_G.os.clock()-s_time 29 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,!gloop(#xx)!{\p1\an7\pos(!xx[j].x+66 !,! xx[j].y+ 200 !)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,耗时为 !dur! 31 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 32 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(79.926305919634,167)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 33 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(81.381622121348,176.96320408003)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 34 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(83.190034290531,186.86811494353)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 35 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(85.468146786592,196.67502126126)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 36 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(88.407019331839,206.30295633967)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 37 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(92.348489453718,215.56042363784)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 38 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(97.949111275511,223.89481526841)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 39 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(106.15998088493,229.52921314731)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 40 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(116.09560871007,229.80072242347)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 41 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(125.38650629994,226.00531875049)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 42 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(133.78093070291,220.45722723711)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 43 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(141.62322648632,214.14413846817)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 44 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(149.17259670297,207.48146053811)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 45 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(156.60412422539,200.687090231)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 46 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(164.04545538435,193.90348064572)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 47 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(171.59799164303,187.24418820188)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 48 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(179.34742344923,180.81563564929)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 49 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(187.36777671913,174.72921681831)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 50 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(195.72027003852,169.10845722629)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 51 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(204.4476462416,164.09111272242)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 52 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(213.56438830847,159.82407454407)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 53 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(223.04632443837,156.44782967741)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 54 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(232.82626996266,154.07101448407)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 55 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(242.8030212308,152.74353462691)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 56 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(252.86377551667,152.44273383712)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 57 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(262.90962124201,153.08123963654)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 58 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(272.8717591047,154.53063665977)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 59 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(282.71456825576,156.64718036158)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 60 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(292.42995596933,159.28988329058)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 61 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(302.02911984882,162.32916883655)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 62 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(311.53532852107,165.64861994942)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 63 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(320.97883868619,169.1429243844)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 64 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(330.39361464061,172.71412004572)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 65 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(339.81519438443,176.2672812085)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 66 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(349.27896299279,179.706188546)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 67 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(358.81814636708,182.9293527991)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 68 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(368.46087259535,185.82693547284)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 69 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(378.22576528014,188.27960668301)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 70 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(388.11599908378,190.16109055359)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 71 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(398.11289959769,191.34656845165)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 72 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(408.17202162535,191.72808412014)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 73 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(418.22592369815,191.23443220235)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 74 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(428.19602313695,189.84791281554)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 75 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(438.0103014535,187.60890492751)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 76 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(447.61884236643,184.60534248946)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 77 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(457.00076232917,180.95320343566)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 78 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(466.16226340623,176.77744281044)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 79 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(475.129892157,172.19916018169)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 80 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(483.94314852737,167.32968110519)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 81 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(492.64857516867,162.26956469833)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 82 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(501.29570239646,157.11026566704)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 83 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(509.93439526418,151.9368305306)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 84 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(518.61295189688,146.83065819773)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 85 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(527.37632888402,141.87174740823)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 86 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(536.26415390944,137.13988960298)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 87 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(545.30816209236,132.71438100286)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 88 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(554.52935382681,128.67164601336)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 89 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(563.93538917989,125.08056993456)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 90 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(573.51929321919,121.99597930196)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 91 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(583.26053768053,119.45180613533)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 92 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(593.12886873138,117.45630073222)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 93 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(603.08994253571,115.99140659387)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 94 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(613.11109546062,115.0168021028)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 95 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(623.16528342038,114.47720346429)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 96 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(633.23275484503,114.31023121207)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 97 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(643.30077608561,114.45199721876)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 98 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(653.36255863116,114.83728094452)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 99 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(663.4167136244,115.38891141243)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 100 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(673.46852893353,115.98255826015)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 101 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(683.53041624509,116.34489939531)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 102 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(693.5712123802,115.75021894392)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 103 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(702.99087661708,112.40820838399)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 104 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(709.84292956126,105.14749234451)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 105 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(714.00383952497,96)\fsc333\c&HFFFFFF&}m 0 0 l 0 1 l 1 1 l 1 0 106 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,耗时为 0.020999999999731 107 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/匀速n阶贝塞尔曲线(精准快速)/匀速贝塞尔曲线.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:23.976000:400000:1920:1080:47:163:254: 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.375000 17 | Active Line: 1 18 | 19 | [V4+ Styles] 20 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 21 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,7,10,10,10,1 22 | Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,7,10,10,10,1 23 | 24 | [Events] 25 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 26 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,Exkit = _G.require('Exkit') 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,px,py={},{} for i=1,20 do local x=(i-1)/20*666+1/20*666*math.random() local y=math.random(-150,150) px[i]=x py[i]=y end 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,xx = Exkit.Bezier_to_px( px , py , 10 ) 29 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,!gloop(#xx)!{\p1\an7\pos(!xx[j].x+66 !,! xx[j].y+ 200 !)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 31 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(80.971588519893,179)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 32 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(86.576189968727,170.68166963465)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 33 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(93.336440107228,163.26168945375)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 34 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(100.79938549727,156.54475411543)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 35 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(108.76618793571,150.4327973513)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 36 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(117.17793282442,144.95002393486)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 37 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(126.04150514763,140.23533879363)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 38 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(135.37510254809,136.54474941489)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 39 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(145.13931377429,134.24010292273)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 40 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(155.1529389901,133.69647499848)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 41 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(165.08309927844,135.09329722026)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 42 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(174.59999704125,138.26580960627)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 43 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(183.54373126052,142.81991416531)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 44 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(191.92387220517,148.34892020516)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 45 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(199.83199913505,154.53730546489)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 46 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(207.37848006056,161.16341564186)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 47 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(214.66737547103,168.07262053399)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 48 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(221.79116572375,175.15230823401)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 49 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(228.83265225438,182.31401457807)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 50 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(235.86885355134,189.48092227082)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 51 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(242.97517729295,196.57818025211)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 52 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(250.22939246551,203.52391406478)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 53 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(257.71499586955,210.21899836596)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 54 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(265.52306041526,216.53390392172)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 55 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(273.74932262731,222.29119417487)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 56 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(282.47974316028,227.24633504786)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 57 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(291.75324048576,231.08186372034)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 58 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(301.50067162831,233.45459961993)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 59 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(311.50874643323,234.13158004509)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 60 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(321.49262244095,233.13756953388)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 61 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(331.2407633478,230.74667623808)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 62 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(340.68231502412,227.33151037004)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 63 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(349.8522531514,223.23793521748)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 64 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(358.83503975455,218.74635122576)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 65 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(367.72922606753,214.08098131784)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 66 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(376.63127328781,209.43068379356)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 67 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(385.62811237945,204.96726291111)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 68 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(394.7912971967,200.85754431784)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 69 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(404.16933429016,197.26717036629)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 70 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(413.77822172417,194.35320490459)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 71 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(423.59451072186,192.2437192912)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 72 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(433.55855017786,191.00903974412)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 73 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(443.59239492237,190.63880401236)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 74 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(453.62588444204,191.03979781613)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 75 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(463.61677585559,192.05561708777)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 76 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(473.55625773079,193.49461153438)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 77 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(483.46197260441,195.15246826848)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 78 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(493.36514561073,196.82560360613)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 79 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(503.29663677789,198.31960588388)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 80 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(513.27450104867,199.45948230396)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 81 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(523.29594776954,200.10642389125)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 82 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(533.33778077735,200.1797389236)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 83 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(543.36735482777,199.67492997864)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 84 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(553.35938347862,198.6670972305)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 85 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(563.30881200328,197.29768006229)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 86 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(573.23291981136,195.75350899988)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 87 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(583.16294139758,194.24834122093)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 88 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(593.1291150342,193.00900239961)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 89 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(603.14313674821,192.2589159118)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 90 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(613.18409213028,192.18655985767)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 91 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(623.20041631711,192.89019318735)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 92 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(633.14217586541,194.30529032058)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 93 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(643.01973110186,196.12307749413)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 94 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(652.94497928813,197.63881871348)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 95 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(662.94719860584,197.3399904499)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 96 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(671.94380466904,193.10484852167)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 97 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(678.4356233962,185.5010847294)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 98 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(682.95559098164,176.54500191903)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 99 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(686.33008631783,167.08907245579)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 100 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(689.00757965502,157.41041706136)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 101 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(691.22410231902,147.61516322134)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 102 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(693.11464598022,137.75148094993)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 103 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(694.76276478952,127.8442730267)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 104 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(696.22357683043,117.90764557634)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 105 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(697.5353035726,107.95019887896)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 106 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(698.72552876597,97.977475348774)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 107 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(699.81481253255,87.993214238296)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 108 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,{\p1\an7\pos(700.81889657163,78)\fsc233\c&H000000&}m 0 0 l 0 1 l 1 1 l 1 0 109 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/各种不归类的函数以及以往的函数库都有可能整合在Exkit里.txt: -------------------------------------------------------------------------------- 1 | 各种不归类的函数以及以往的函数库都有可能整合在Exkit里 -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/超高精度数值积分/其它说明.txt: -------------------------------------------------------------------------------- 1 | 注意:对于不收敛的积分,自然不会得到正确结果 2 | 3 | 4 | 还有就是:该方法只是总的来说比其它方法的数值积分更高精度,并不代表能绝对正确 5 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/超高精度数值积分/高精度数值积分 例一.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:60.000000:19000:1920:1080:0:0:0:c 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.375000 17 | Active Line: 3 18 | 19 | [V4+ Styles] 20 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 21 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 22 | Style: Default,黑体,90,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1 23 | 24 | [Events] 25 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 26 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,Exkit = _G.require('Exkit') 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,sin=math.sin cos=math.cos acos= math.acos cosh= math.cosh tan= math.tan exp= math.exp 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,function f(t) return exp(-t/3)*sin(3*t)*cos(t/4+t*t); end 29 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,标准答案,可以在这个网站查看该积分的准确答案,结果超级精确:https://www.wolframalpha.com/input?i2d=true&i=Integrate%5Bexp%5C%2840%29-Divide%5Bx%2C3%5D%5C%2841%29sin3xcos%5C%2840%29Divide%5Bx%2C4%5D%2Bxx%5C%2841%29%2C%7Bx%2C-0%2C100%7D%5D 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,xx=Exkit.integrator( f , 0 , 100 ) 31 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,! xx ! 32 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 33 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,0.80285527312534 34 | -------------------------------------------------------------------------------- /flex/不归类函数/诸如字幕/超高精度数值积分/高精度数值积分 例二.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.2.2 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: None 9 | PlayResX: 1920 10 | PlayResY: 1080 11 | 12 | [Aegisub Project Garbage] 13 | Last Style Storage: Default 14 | Video File: ?dummy:60.000000:19000:1920:1080:0:0:0:c 15 | Video AR Value: 1.777778 16 | Video Zoom Percent: 0.375000 17 | Active Line: 4 18 | 19 | [V4+ Styles] 20 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 21 | Style: Default-furigana,Arial,10,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 22 | Style: Default,黑体,90,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1 23 | 24 | [Events] 25 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 26 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,Exkit = _G.require('Exkit') 27 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,sin=math.sin cos=math.cos acos= math.acos cosh= math.cosh tan= math.tan exp= math.exp 28 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,function f(x) return exp(-x/66) end 29 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,标准答案,可以在这个网站查看该积分的准确答案,结果超级精确:https://www.wolframalpha.com/input?i2d=true&i=Integrate%5Bexp%5C%2840%29-Divide%5Bx%2C66%5D%5C%2841%29%2C%7Bx%2C0%2C%2B%E2%88%9E%7D%5D 30 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,xx=Exkit.integrator( f , 0 , math.huge ) 31 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line notext,! xx ! 32 | Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke, 33 | Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,fx,66 34 | -------------------------------------------------------------------------------- /flex/分形噪声/noise初.lua: -------------------------------------------------------------------------------- 1 | 2 | local noise={perm={}} 3 | 4 | local floor=math.floor 5 | 6 | local function fade(t) 7 | return t*t*t*(t*(t*6-15)+10) 8 | end 9 | 10 | local function lerp(t,a,b) 11 | return a+t*(b-a) 12 | end 13 | 14 | local function grad1d(hash,x) 15 | local h=bit.band(hash,15) 16 | return (bit.band(h,1)==0 and x or -x) 17 | end 18 | 19 | function noise.perlin1d(x) 20 | local X=bit.band(floor(x),255) x=x-floor(x) 21 | return lerp(fade(x),grad1d(noise.perm[X],x),grad1d(noise.perm[X+1],x-1))*2 22 | end 23 | 24 | local function grad2d(hash,x,y) 25 | local h=bit.band(hash,15) 26 | local u,v=h<8 and x or y,h<4 and y or x 27 | return (bit.band(h,1)==0 and u or -u)+(bit.band(h,2)==0 and v or -v) 28 | end 29 | 30 | function noise.perlin2d(x,y) 31 | local X,Y=bit.band(floor(x),255),bit.band(floor(y),255) x,y=x-floor(x),y-floor(y) 32 | local u,v=fade(x),fade(y) 33 | local A=noise.perm[X]+Y 34 | local B=noise.perm[X+1]+Y 35 | local a1=lerp(u,grad2d(noise.perm[A],x,y),grad2d(noise.perm[B],x-1,y)) 36 | local a2=lerp(u,grad2d(noise.perm[A+1],x,y-1),grad2d(noise.perm[B+1],x-1,y-1)) 37 | return lerp(v,a1,a2) 38 | end 39 | 40 | local function grad3d(hash,x,y,z) 41 | local h=bit.band(hash,15) 42 | local u,v=h<8 and x or y,h<4 and y or ((h==12 or h==14) and x or z) 43 | return (bit.band(h,1)==0 and u or -u)+(bit.band(h,2)==0 and v or -v) 44 | end 45 | 46 | function noise.perlin3d(x,y,z) 47 | local X,Y,Z=bit.band(floor(x),255),bit.band(floor(y),255),bit.band(floor(z),255) 48 | x,y,z=x-floor(x),y-floor(y),z-floor(z) 49 | local u,v,w=fade(x),fade(y),fade(z) 50 | local A=noise.perm[X]+Y 51 | local AA=noise.perm[A]+Z 52 | local AB=noise.perm[A+1]+Z 53 | local B=noise.perm[X+1]+Y 54 | local BA=noise.perm[B]+Z 55 | local BB=noise.perm[B+1]+Z 56 | local a1=lerp(u,grad3d(noise.perm[AA],x,y,z),grad3d(noise.perm[BA],x-1,y,z)) 57 | local a2=lerp(u,grad3d(noise.perm[AB],x,y-1,z),grad3d(noise.perm[BB],x-1,y-1,z)) 58 | local b1=lerp(u,grad3d(noise.perm[AA+1],x,y,z-1),grad3d(noise.perm[BA+1],x-1,y,z-1)) 59 | local b2=lerp(u,grad3d(noise.perm[AB+1],x,y-1,z-1),grad3d(noise.perm[BB+1],x-1,y-1,z-1)) 60 | return lerp(w,lerp(v,a1,a2),lerp(v,b1,b2)) 61 | end 62 | 63 | function noise.fbm(x,y,z,func,octaves,lacunarity,gain) 64 | octaves=octaves or 8 65 | lacunarity=lacunarity or 2 66 | gain=gain or 0.5 func=func or noise.perlin3d 67 | local amplitude=1.0 68 | local frequency=1.0 69 | local sum=0.0 local max=0 70 | for _=0,octaves do 71 | sum=sum+amplitude*func(x*frequency,y*frequency,z*frequency) 72 | max=max+amplitude amplitude=amplitude*gain 73 | frequency=frequency*lacunarity 74 | end 75 | return sum/max 76 | end 77 | 78 | function noise.get_perm(seed) 79 | if seed then math.randomseed(seed) end 80 | for i=0,255 do 81 | noise.perm[i]=math.random(0,255) noise.perm[i+256]=noise.perm[i] 82 | end 83 | end 84 | 85 | function noise.initialize() 86 | noise.get_perm() 87 | end 88 | 89 | noise.initialize() 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | _G.noise=noise 99 | return _G.noise 100 | 101 | -------------------------------------------------------------------------------- /flex/分形噪声/以后会更新该库,但b站更新才会更: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /flex/分形噪声/更新/noise.lua: -------------------------------------------------------------------------------- 1 | 2 | local noise={perm={}} 3 | 4 | local floor=math.floor 5 | 6 | local function fade(t) 7 | return t*t*t*(t*(t*6-15)+10) 8 | end 9 | 10 | local function lerp(t,a,b) 11 | return a+t*(b-a) 12 | end 13 | 14 | local function grad1d(hash,x) 15 | local h=bit.band(hash,15) 16 | return (bit.band(h,1)==0 and x or -x) 17 | end 18 | 19 | function noise.perlin1d(x) 20 | local X=bit.band(floor(x),255) x=x-floor(x) 21 | return lerp(fade(x),grad1d(noise.perm[X],x),grad1d(noise.perm[X+1],x-1))*2 22 | end 23 | 24 | local function grad2d(hash,x,y) 25 | local h=bit.band(hash,15) 26 | local u,v=h<8 and x or y,h<4 and y or x 27 | return (bit.band(h,1)==0 and u or -u)+(bit.band(h,2)==0 and v or -v) 28 | end 29 | 30 | function noise.perlin2d(x,y) 31 | local X,Y=bit.band(floor(x),255),bit.band(floor(y),255) x,y=x-floor(x),y-floor(y) 32 | local u,v=fade(x),fade(y) 33 | local A=noise.perm[X]+Y 34 | local B=noise.perm[X+1]+Y 35 | local a1=lerp(u,grad2d(noise.perm[A],x,y),grad2d(noise.perm[B],x-1,y)) 36 | local a2=lerp(u,grad2d(noise.perm[A+1],x,y-1),grad2d(noise.perm[B+1],x-1,y-1)) 37 | return lerp(v,a1,a2) 38 | end 39 | 40 | local function grad3d(hash,x,y,z) 41 | local h=bit.band(hash,15) 42 | local u,v=h<8 and x or y,h<4 and y or ((h==12 or h==14) and x or z) 43 | return (bit.band(h,1)==0 and u or -u)+(bit.band(h,2)==0 and v or -v) 44 | end 45 | 46 | function noise.perlin3d(x,y,z) 47 | local X,Y,Z=bit.band(floor(x),255),bit.band(floor(y),255),bit.band(floor(z),255) 48 | x,y,z=x-floor(x),y-floor(y),z-floor(z) 49 | local u,v,w=fade(x),fade(y),fade(z) 50 | local A=noise.perm[X]+Y 51 | local AA=noise.perm[A]+Z 52 | local AB=noise.perm[A+1]+Z 53 | local B=noise.perm[X+1]+Y 54 | local BA=noise.perm[B]+Z 55 | local BB=noise.perm[B+1]+Z 56 | local a1=lerp(u,grad3d(noise.perm[AA],x,y,z),grad3d(noise.perm[BA],x-1,y,z)) 57 | local a2=lerp(u,grad3d(noise.perm[AB],x,y-1,z),grad3d(noise.perm[BB],x-1,y-1,z)) 58 | local b1=lerp(u,grad3d(noise.perm[AA+1],x,y,z-1),grad3d(noise.perm[BA+1],x-1,y,z-1)) 59 | local b2=lerp(u,grad3d(noise.perm[AB+1],x,y-1,z-1),grad3d(noise.perm[BB+1],x-1,y-1,z-1)) 60 | return lerp(w,lerp(v,a1,a2),lerp(v,b1,b2)) 61 | end 62 | 63 | function noise.fbm(x,y,z,func,octaves,lacunarity,gain) 64 | octaves=octaves or 8 65 | lacunarity=lacunarity or 2 66 | gain=gain or 0.5 func=func or noise.perlin3d 67 | local amplitude=1.0 68 | local frequency=1.0 69 | local sum=0.0 local max=0 70 | for _=0,octaves do 71 | sum=sum+amplitude*func(x*frequency,y*frequency,z*frequency) 72 | max=max+amplitude amplitude=amplitude*gain 73 | frequency=frequency*lacunarity 74 | end 75 | return sum/max 76 | end 77 | 78 | function noise.get_perm(seed) 79 | if seed then math.randomseed(seed) end 80 | for i=0,255 do 81 | noise.perm[i]=math.random(0,255) noise.perm[i+256]=noise.perm[i] 82 | end 83 | end 84 | 85 | function noise.initialize() 86 | noise.get_perm() 87 | end 88 | 89 | noise.initialize() 90 | 91 | --[[ 92 | 0: basic 93 | 1: turbulent smooth 94 | 2: turbulent basic 95 | 3: turbulent sharp 96 | 4: dynamic 97 | ]] 98 | noise.fractal_type=0 99 | 100 | --[[ 101 | 0: block 102 | 1: linear 103 | 2: softlinear 104 | 3: spline 105 | ]] 106 | noise.type=3 107 | 108 | noise.rnd_seed=233 109 | 110 | function noise.set_seed(seed) 111 | if seed then math.randomseed(seed) end noise.rnd_seed=math.random(23333)*math.random() 112 | end 113 | 114 | noise.invert=false 115 | 116 | noise.contrast=1 117 | 118 | noise.comp_val=0.5 119 | 120 | noise.brightness=0 121 | 122 | --[[ 123 | 0: clip 124 | 1: soft clamp 125 | 2: wrap back 126 | 3: allow hdr results 127 | ]] 128 | noise.overflow=0 129 | 130 | noise.rotation=0 131 | 132 | noise.complexity=5 133 | 134 | noise.sub_influence=0.7 135 | 136 | noise.sub_scale=0.57 137 | 138 | noise.sub_rotation=0 139 | 140 | noise.sub_xoff=0 141 | 142 | noise.sub_yoff=0 143 | 144 | noise.center_subscale=false 145 | 146 | noise.evo=0 147 | 148 | noise.cycle=false 149 | 150 | 151 | local function mod(x,y) return x-y*math.floor(x/y) end 152 | 153 | local function fract(n,_) 154 | if type(n)=="table" then 155 | for i=1,#n do 156 | _,n[i]=math.modf(n[i]) n[i]=n[i]<0 and n[i]+1 or n[i] 157 | end 158 | else _,n=math.modf(n) n=n<0 and n+1 or n 159 | end 160 | return n 161 | end 162 | 163 | local function hash33(v) 164 | local v=fract({v[1]*0.1031,v[2]*0.1030,v[3]*0.0973}) 165 | local n=(v[2]+23.33)*v[1]+(v[1]+23.33)*v[2]+(v[3]+23.33)*v[3] 166 | v={v[1]+n,v[2]+n,v[3]+n} 167 | return fract({(v[1]+v[2])*v[3],v[1]*2*v[2],(v[1]+v[2])*v[1]}) 168 | end 169 | 170 | local function bicubic(a,b,c,d,f) 171 | local f2=1-f 172 | local w0=1/6*f2^3 173 | local w1=2/3-0.5*f^2*(2-f) 174 | local w2=2/3-0.5*f2^2*(1+f) 175 | local w3=1/6*f^3 176 | return w0*a+w1*b+w2*c+w3*d 177 | end 178 | 179 | local function wrap(value,min,max) 180 | return mod(value-min,max-min)+min 181 | end 182 | 183 | local function tur_basic(f) 184 | return math.abs((f-0.5)*1.2)*2 185 | end 186 | 187 | local function tur_smooth(f) 188 | local t=tur_basic(f) 189 | return t^2 190 | end 191 | 192 | local function tur_sharp(f) 193 | local t=tur_basic(f) 194 | return t^0.5 195 | end 196 | 197 | local function select_fractal(f,typ) 198 | if typ==0 then 199 | return f 200 | elseif typ==1 then 201 | return tur_smooth(f) 202 | elseif typ==2 then 203 | return tur_basic(f) 204 | elseif typ==3 then 205 | return tur_sharp(f) 206 | else return f 207 | end 208 | end 209 | 210 | local function select_cycle(value,base,periode) 211 | local ret=0 212 | if noise.cycle then 213 | ret=wrap(value,base,base+periode) 214 | else ret=value 215 | end 216 | return ret 217 | end 218 | 219 | local function block(x,y,depth,evo,cycle,center_subscale) 220 | local rnd=noise.rnd_seed if center_subscale then rnd=rnd+depth end 221 | local hash=hash33({floor(x),floor(y),rnd}) local freq,periode=hash[1],1 222 | if cycle then 223 | freq=periode/cycle 224 | end 225 | evo=evo*freq+hash[2] local e,f=rnd+floor(evo),fract(evo) 226 | local a=hash33({floor(x),floor(y),select_cycle(e-1,rnd,periode)}) 227 | local b=hash33({floor(x),floor(y),select_cycle(e,rnd,periode)}) 228 | local c=hash33({floor(x),floor(y),select_cycle(e+1,rnd,periode)}) 229 | local d=hash33({floor(x),floor(y),select_cycle(e+2,rnd,periode)}) 230 | return bicubic(a[1],b[1],c[1],d[1],f) 231 | end 232 | 233 | local function linear(x,y,depth,evo,cycle,center_subscale) 234 | local tl=block(x,y,depth,evo,cycle,center_subscale) 235 | local tr=block(x+1,y,depth,evo,cycle,center_subscale) 236 | local bl=block(x,y+1,depth,evo,cycle,center_subscale) 237 | local br=block(x+1,y+1,depth,evo,cycle,center_subscale) 238 | local fx,fy=fract(x),fract(y) 239 | return lerp(fy,lerp(fx,tl,tr), lerp(fx,bl,br)) 240 | end 241 | 242 | local function soft_linear(x,y,depth,evo,cycle,center_subscale) 243 | local tl=block(x,y,depth,evo,cycle,center_subscale) 244 | local tr=block(x+1,y,depth,evo,cycle,center_subscale) 245 | local bl=block(x,y+1,depth,evo,cycle,center_subscale) 246 | local br=block(x+1,y+1,depth,evo,cycle,center_subscale) 247 | local fx,fy=fract(x),fract(y) fx,fy=3*fx^2-2*fx^3,3*fy^2-2*fy^3 248 | return lerp(fy,lerp(fx,tl,tr), lerp(fx,bl,br)) 249 | end 250 | 251 | local function spline(x,y,depth,evo,cycle,center_subscale) 252 | local ttll=block(x-1,y-1,depth,evo,cycle,center_subscale) 253 | local ttl=block(x,y-1,depth,evo,cycle,center_subscale) 254 | local ttr=block(x+1,y-1,depth,evo,cycle,center_subscale) 255 | local ttrr=block(x+2,y-1,depth,evo,cycle,center_subscale) 256 | 257 | local tll=block(x-1,y,depth,evo,cycle,center_subscale) 258 | local tl=block(x,y,depth,evo,cycle,center_subscale) 259 | local tr=block(x+1,y,depth,evo,cycle,center_subscale) 260 | local trr=block(x+2,y,depth,evo,cycle,center_subscale) 261 | 262 | local bll=block(x-1,y+1,depth,evo,cycle,center_subscale) 263 | local bl=block(x,y+1,depth,evo,cycle,center_subscale) 264 | local br=block(x+1,y+1,depth,evo,cycle,center_subscale) 265 | local brr=block(x+2,y+1,depth,evo,cycle,center_subscale) 266 | 267 | local bbll=block(x-1,y+2,depth,evo,cycle,center_subscale) 268 | local bbl=block(x,y+2,depth,evo,cycle,center_subscale) 269 | local bbr=block(x+1,y+2,depth,evo,cycle,center_subscale) 270 | local bbrr=block(x+2,y+2,depth,evo,cycle,center_subscale) 271 | local fx,fy=fract(x),fract(y) 272 | local tt=bicubic(ttll,ttl,ttr,ttrr,fx) local t=bicubic(tll,tl,tr,trr,fx) 273 | local b=bicubic(bll,bl,br,brr,fx) local bb=bicubic(bbll,bbl,bbr,bbrr,fx) 274 | local ret=bicubic(tt,t,b,bb,fy) 275 | return (ret-0.5)*1.5+0.5 276 | end 277 | 278 | local function clip(value) 279 | return value<0 and 0 or value>1 and 1 or value 280 | end 281 | 282 | local function soft_clamp(value) 283 | return 1/(1+math.exp(2-4*value)) 284 | end 285 | 286 | local function wrap_back(value) 287 | return math.abs(value-2*floor(value*0.5+0.5)) 288 | end 289 | 290 | local function allow_hdr(value) 291 | return value 292 | end 293 | 294 | local function select_overflow(value,overflow) 295 | if overflow==0 then 296 | return clip(value) 297 | elseif overflow==1 then 298 | return soft_clamp(value) 299 | elseif overflow==1 then 300 | return wrap_back(value) 301 | else 302 | return allow_hdr(value) 303 | end 304 | end 305 | 306 | local function layer(fractal_type,noise_type,x,y,depth,evo,cycle,center_subscale) 307 | local ret=0 308 | if noise_type==0 then 309 | ret=block(x,y,depth,evo,cycle,center_subscale) 310 | elseif noise_type==1 then 311 | ret=linear(x,y,depth,evo,cycle,center_subscale) 312 | elseif noise_type==2 then 313 | ret=soft_linear(x,y,depth,evo,cycle,center_subscale) 314 | elseif noise_type==3 then 315 | ret=spline(x,y,depth,evo,cycle,center_subscale) 316 | else 317 | ret=spline(x,y,depth,evo,cycle,center_subscale) 318 | end 319 | return select_fractal(ret,fractal_type) 320 | end 321 | 322 | function noise.fractal(x,y,scale_x,scale_y,depth,evo,cycle) 323 | local evo=evo or noise.evo local cycle=cycle or noise.cycle 324 | local center_subscale=noise.center_subscale local depth=depth or noise.complexity 325 | local fractal_type,noise_type=noise.fractal_type,noise.type 326 | local x1=x*math.cos(math.rad(noise.rotation))-y*math.sin(math.rad(noise.rotation)) 327 | local y1=x*math.sin(math.rad(noise.rotation))+y*math.cos(math.rad(noise.rotation)) 328 | local val,tot_weight=0,0 local fsc,xoff,yoff,roll,weight=1,0,0,0,1 local new_x,new_y 329 | for i=1,depth do 330 | x1,y1=(x1+xoff)/fsc,(y1+yoff)/fsc 331 | new_x=x1*math.cos(math.rad(roll))-y1*math.sin(math.rad(roll)) 332 | new_y=x1*math.sin(math.rad(roll))+y1*math.cos(math.rad(roll)) 333 | val=val+layer(fractal_type,noise_type,new_x/scale_x,new_y/scale_y,i,evo,cycle,center_subscale)*weight 334 | xoff,yoff=xoff+noise.sub_xoff,yoff+noise.sub_yoff 335 | fsc=fsc*noise.sub_scale roll=noise.sub_rotation+roll 336 | tot_weight=tot_weight+weight weight=weight*noise.sub_influence 337 | end 338 | local f=fract(depth) 339 | x1,y1=(x1+xoff)/fsc,(y1+yoff)/fsc 340 | new_x=x1*math.cos(math.rad(roll))-y1*math.sin(math.rad(roll)) 341 | new_y=x1*math.sin(math.rad(roll))+y1*math.cos(math.rad(roll)) 342 | val=val+layer(fractal_type,noise_type,new_x/scale_x,new_y/scale_y,floor(depth)+1,evo,cycle,center_subscale)*weight*f 343 | tot_weight=tot_weight+weight*f val=val/tot_weight if noise.invert then val=1-val end 344 | val=(val-noise.comp_val)*noise.contrast+noise.comp_val val=select_overflow(val+noise.brightness,noise.overflow) 345 | return (val-0.5)*2,val 346 | end 347 | 348 | function noise.re_map_range(val,a,b,new_a,new_b) 349 | return (val-a)/(b-a)*(new_b-new_a)+new_a 350 | end 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | _G.noise=noise 362 | return _G.noise 363 | 364 | -------------------------------------------------------------------------------- /flex/和b站同步更新: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /多边形库/ployc优化更新版/polyc.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | --自己瞎写的破烂函数库 4 | --我b站账号:https://space.bilibili.com/346816900 5 | --Aegisub视频整合:https://space.bilibili.com/346816900/channel/seriesdetail?sid=231885 6 | --如果没有polyb,请注释掉第855到第865行。(以后我会发出相应的文件,可以留意一下更新) 7 | --转载请注明作者和出处! 8 | 9 | local polyc={} 10 | 11 | local function math_round(n,digit) 12 | if digit and digit>=1 then 13 | digit=10^math.floor(digit) 14 | return math.floor(n*digit+0.5)/digit 15 | else return math.floor(n+0.5) 16 | end 17 | end 18 | 19 | function polyc.rand_coor(n,x0,y0,w,h) 20 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 21 | for i=1,n do 22 | coor[i]={x0+w*(i-1)/n+w/n*math.random(),y0+h*math.random()} 23 | end 24 | return coor,sup 25 | end 26 | 27 | function polyc.rand_coor2(n,n2,x0,y0,w,h) 28 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 29 | for i=1,n do 30 | for i1=1,n2 do 31 | local x=x0+w*(i-1)/n+w/n*math.random() 32 | local y=y0+h*(i1-1)/n2+h/n2*math.random() 33 | coor[#coor+1]={x,y} 34 | end 35 | end 36 | return coor,sup 37 | end 38 | 39 | function polyc.rand_coor_rect(n,n2,x0,y0,w,h) 40 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 41 | for i=1,n do 42 | for i1=1,n2 do 43 | local x=i==1 and x0 or (i==n and x0+w or x0+w*(i-1)/n+w/n*math.random()) 44 | local y=i1==1 and y0 or (i1==n2 and y0+h or y0+h*(i1-1)/n2+h/n2*math.random()) 45 | coor[#coor+1]={x,y} 46 | end 47 | end 48 | return coor,sup 49 | end 50 | 51 | function polyc.rand_coor_circle(n,n2,x0,y0,R)--园内n个点,圆上n2个点 52 | local coor={} local sup={{x0-R*10,y0+R*10},{x0+20*R,y0+R*10},{x0+R/2,y0-R*10}} 53 | local deg=math.rad(360/n2) 54 | for i=1,n do 55 | local x=x0-R/2+R*(i-1)/n+R/n*math.random() local y=((R/2)^2-(x-x0)^2)^0.5 y=y0+math.random(-y,y) 56 | coor[i]={x,y} 57 | end 58 | for i=1,n2 do 59 | local d=deg*math.random() 60 | coor[n+i]={x0+R/2*math.cos((i-1)*deg+d),y0+R/2*math.sin((i-1)*deg+d)} 61 | end 62 | return coor,sup 63 | end 64 | 65 | local function circumcircle(tri) 66 | local x1,y1=tri[1][1],tri[1][2] local x2,y2=tri[2][1],tri[2][2] local x3,y3=tri[3][1],tri[3][2] 67 | local x=((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2*(x3-x1)*(y2-y1)-2*((x2-x1)*(y3-y1))) 68 | local y=((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2*(y3-y1)*(x2-x1)-2*((y2-y1)*(x3-x1))) 69 | local r=((x-x1)^2+(y-y1)^2)^0.5 local cir={x=x,y=y,r=r} 70 | return cir 71 | end 72 | 73 | local function circumcircle2(tri)--只计算外接圆圆心 74 | local x1,y1=tri[1][1],tri[1][2] local x2,y2=tri[2][1],tri[2][2] local x3,y3=tri[3][1],tri[3][2] 75 | local x=((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2*(x3-x1)*(y2-y1)-2*((x2-x1)*(y3-y1))) 76 | local y=((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2*(y3-y1)*(x2-x1)-2*((y2-y1)*(x3-x1))) 77 | return {x=x,y=y} 78 | end 79 | 80 | local function check_p(tri,p) 81 | local cir=circumcircle(tri) 82 | if (p[1]-cir.x)^2+(p[2]-cir.y)^21 then return true end 186 | end 187 | end 188 | return false 189 | end 190 | 191 | local function tri_sort(tris,p) 192 | local function get_coor(tri,p1,p2) 193 | for i=1,3 do 194 | if check({tri[i]},p1)==false and check({tri[i]},p2)==false then 195 | return tri[i] 196 | end 197 | end 198 | end 199 | local point local sort,edges={},{} 200 | for i=1,#tris do 201 | for i1=1,3 do 202 | if tris_include_p(tris,tris[i][i1])==false and check({tris[i][i1]},p)==false then 203 | sort[#sort+1]=tris[i] point=tris[i][i1] edges[#edges+1]=point 204 | point=get_coor(tris[i],p,point) edges[#edges+1]=point table.remove(tris,i) break 205 | end 206 | end 207 | if #sort>0 then break end 208 | end 209 | if #sort==0 then 210 | for i=1,#tris[1] do 211 | if tris[1][i][1]~=p[1] or tris[1][i][2]~=p[2] then 212 | sort[1]=tris[1] point=tris[1][i] edges[1]=point table.remove(tris,1) break 213 | end 214 | end 215 | end 216 | for _=1,#tris do 217 | for i=#tris,1,-1 do 218 | if check(tris[i],point) then 219 | sort[#sort+1]=tris[i] point=get_coor(tris[i],p,point) edges[#edges+1]=point 220 | table.remove(tris,i) break 221 | end 222 | end 223 | end 224 | return sort,edges 225 | end 226 | 227 | local function h_line_seg_isect(x1,y1,x2,y2,y)--水平线和线段交点 228 | local top,bottom=math.min(y1,y2),math.max(y1,y2) 229 | if y>=top and y<=bottom then 230 | return x1+((x2-x1)/(y2-y1))*(y-y1) 231 | end 232 | end 233 | 234 | local function h_line_isect(x1,y1,x2,y2,y)--水平线和直线交点 235 | return x1+((x2-x1)/(y2-y1))*(y-y1) 236 | end 237 | 238 | local function v_line_isect(x1,y1,x2,y2,x)--竖直线和直线交点 239 | return y1+((y2-y1)/(x2-x1))*(x-x1) 240 | end 241 | 242 | local function v_line_seg_isect(x1,y1,x2,y2,x)--竖直线和线段交点 243 | local left,right=math.min(x1,x2),math.max(x1,x2) 244 | if x>=left and x<=right then 245 | return y1+((y2-y1)/(x2-x1))*(x-x1) 246 | end 247 | end 248 | 249 | local function sgn(n) 250 | return n>0 and 1 or n<0 and -1 or 0 251 | end 252 | 253 | local function rect_seg_intersection(seg,x0,y0,w,h) 254 | local p={} 255 | local x1=h_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],y0) 256 | local x2=h_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],y0+h) 257 | local y1=v_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],x0) 258 | local y2=v_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],x0+w) 259 | if x1 and x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2 and x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 261 | if #p==2 then 262 | local dx,dy,dx1,dy1=seg[2][1]-seg[1][1],seg[2][2]-seg[1][2],p[2][1]-p[1][1],p[2][2]-p[1][2] 263 | if math.abs(dx)>1 then 264 | if sgn(dx)~=sgn(dx1) then p={p[2],p[1]} end 265 | else 266 | if math.abs(dy)>1 then 267 | if sgn(dy)~=sgn(dy1) then p={p[2],p[1]} end 268 | else 269 | if sgn(dx)~=sgn(dx1) or sgn(dy)~=sgn(dy1) then 270 | p={p[2],p[1]} 271 | end 272 | end 273 | end 274 | end 275 | return p 276 | end 277 | 278 | local function rect_ray_intersection(ray,x0,y0,w,h) 279 | local p,insect,dx,dy={},{},ray[2][1]-ray[1][1],ray[2][2]-ray[1][2] 280 | local x1=h_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],y0) 281 | local x2=h_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],y0+h) 282 | local y1=v_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],x0) 283 | local y2=v_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],x0+w) 284 | if x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 286 | for i=1,#p do 287 | if math.abs(dx)>1 then 288 | local dx1=p[i][1]-ray[1][1] 289 | if sgn(dx)==sgn(dx1) then insect[#insect+1]=p[i] end 290 | else 291 | if math.abs(dy)>1 then 292 | local dy1=p[i][2]-ray[1][2] 293 | if sgn(dy)==sgn(dy1) then insect[#insect+1]=p[i] end 294 | else 295 | local dx1,dy1=p[i][1]-ray[1][1],p[i][2]-ray[1][2] 296 | if sgn(dx)==sgn(dx1) and sgn(dy)==sgn(dy1) then 297 | insect[#insect+1]=p[i] 298 | end 299 | end 300 | end 301 | if p[i][1]==ray[1][1] and p[i][2]==ray[1][2] then--如果矩形和射线的交点刚好是射线的端点 302 | insect[#insect+1]=p[i] 303 | end 304 | end 305 | if #insect==2 then 306 | local dx1,dy1=insect[2][1]-insect[1][1],insect[2][2]-insect[1][2] 307 | if math.abs(dx)>1 then 308 | if sgn(dx)~=sgn(dx1) then insect={insect[2],insect[1]} end 309 | else 310 | if math.abs(dy)>1 then 311 | if sgn(dy)~=sgn(dy1) then insect={insect[2],insect[1]} end 312 | else 313 | if sgn(dx)~=sgn(dx1) or sgn(dy)~=sgn(dy1) then 314 | insect={insect[2],insect[1]} 315 | end 316 | end 317 | end 318 | end 319 | return insect 320 | end 321 | 322 | local function rect_line_intersection(line,x0,y0,w,h) 323 | local p={} 324 | local x1=h_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],y0) 325 | local x2=h_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],y0+h) 326 | local y1=v_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],x0) 327 | local y2=v_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],x0+w) 328 | if x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 330 | return p 331 | end 332 | 333 | local function pt_orientation(p_x,p_y,q_x,q_y,r_x,r_y) 334 | local o=(q_y-p_y)*(r_x-q_x)-(q_x-p_x)*(r_y-q_y) if math.abs(o)<1e-9 then return 0 end 335 | return o>0 and 1 or o<0 and -1 or 0 336 | end 337 | 338 | local function on_rect_edge(p,x0,y0,w,h)--p点处于矩形哪一条边上 339 | if p[1]==x0 then 340 | return {x0,y0},{x0,y0+h} 341 | elseif p[1]==x0+w then 342 | return {x0+w,y0},{x0+w,y0+h} 343 | elseif p[2]==y0 then 344 | return {x0,y0},{x0+w,y0} 345 | elseif p[2]==y0+h then 346 | return {x0,y0+h},{x0+w,y0+h} 347 | end 348 | end 349 | 350 | local function only_one_corner(p1,p2,x0,y0,w,h) 351 | local p1x,p1y,p2x,p2y=p1[1],p1[2],p2[1],p2[2] 352 | if p1x==x0 and p2x~=x0 and p2x~=x0+w then 353 | if p2y==y0 then 354 | return {x0,y0} 355 | end 356 | if p2y==y0+h then 357 | return {x0,y0+h} 358 | end 359 | end 360 | if p1x==x0+w and p2x~=x0+w and p2x~=x0 then 361 | if p2y==y0 then 362 | return {x0+w,y0} 363 | end 364 | if p2y==y0+h then 365 | return {x0+w,y0+h} 366 | end 367 | end 368 | if p2x==x0 and p1x~=x0 and p1x~=x0+w then 369 | if p1y==y0 then 370 | return {x0,y0} 371 | end 372 | if p1y==y0+h then 373 | return {x0,y0+h} 374 | end 375 | end 376 | if p2x==x0+w and p1x~=x0+w and p1x~=x0 then 377 | if p1y==y0 then 378 | return {x0+w,y0} 379 | end 380 | if p1y==y0+h then 381 | return {x0+w,y0+h} 382 | end 383 | end 384 | end 385 | 386 | local function on_the_same_edge(p1,p2,x0,y0,w,h)--p1、p2两点在矩形的同一条边上 387 | local p1x,p1y,p2x,p2y=p1[1],p1[2],p2[1],p2[2] 388 | if p1x==x0 and p2x==x0 then return true end if p1x==x0+w and p2x==x0+w then return true end 389 | if p1y==y0 and p2y==y0 then return true end if p1y==y0+h and p2y==y0+h then return true end 390 | end 391 | 392 | local function add_corner(cell,p,x0,y0,w,h) 393 | local first,last=cell[1],cell[#cell] 394 | if on_the_same_edge(first,last,x0,y0,w,h)~=true then 395 | local corner=only_one_corner(first,last,x0,y0,w,h) 396 | if corner then 397 | local o1=pt_orientation(first[1],first[2],cell[2][1],cell[2][2],p[1],p[2]) 398 | local o2=pt_orientation(corner[1],corner[2],first[1],first[2],cell[2][1],cell[2][2]) 399 | if o1==o2 then--只添加一个角落 400 | cell[#cell+1]=corner 401 | else--需要添加三个角 402 | local tmp1,tmp2=on_rect_edge(last,x0,y0,w,h) 403 | if tmp1[1]==corner[1] and tmp1[2]==corner[2] then 404 | cell[#cell+1]=tmp2 405 | else cell[#cell+1]=tmp1 406 | end 407 | if corner[1]==cell[#cell][1] then 408 | if cell[#cell][1]==x0 then 409 | cell[#cell+1]={x0+w,cell[#cell][2]} 410 | else cell[#cell+1]={x0,cell[#cell][2]} 411 | end 412 | else 413 | if cell[#cell][2]==y0 then 414 | cell[#cell+1]={cell[#cell][1],y0+h} 415 | else cell[#cell+1]={cell[#cell][1],y0} 416 | end 417 | end 418 | tmp1,tmp2=on_rect_edge(first,x0,y0,w,h) 419 | if tmp1[1]==corner[1] and tmp1[2]==corner[2] then 420 | cell[#cell+1]=tmp2 421 | else cell[#cell+1]=tmp1 422 | end 423 | end 424 | else--需要添加两个角 425 | local tmp1,tmp2=on_rect_edge(last,x0,y0,w,h) 426 | local o1=pt_orientation(first[1],first[2],cell[2][1],cell[2][2],p[1],p[2]) 427 | local o2=pt_orientation(cell[#cell-1][1],cell[#cell-1][2],last[1],last[2],tmp1[1],tmp1[2]) 428 | if o1==o2 then cell[#cell+1]=tmp1 else cell[#cell+1]=tmp2 end 429 | tmp1,tmp2=on_rect_edge(first,x0,y0,w,h) 430 | if tmp1[1]==cell[#cell][1] or tmp1[2]==cell[#cell][2] then 431 | cell[#cell+1]=tmp1 432 | else cell[#cell+1]=tmp2 433 | end 434 | end 435 | end 436 | return cell 437 | end 438 | 439 | local function one_tri_and_circ_outside_the_rect(edges,cp,cir,x0,y0,w,h) 440 | local e1,e2=edges[1],edges[2] local pts 441 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 442 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 443 | local mid1,mid2={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2},{(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 444 | if o1==o2 then--说明外心不在两条边的同一侧,所以算射线和矩形交点时只需要其中一条边,另一条边忽略 445 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 446 | if o1~=o3 then--那么edge[1]就是需要的边,第二条边edge[2]用不上了 447 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 448 | else 449 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 450 | end 451 | pts=add_corner(pts,cp,x0,y0,w,h) 452 | else 453 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 454 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 455 | if on_the_same_edge(pts[2],p[2],x0,y0,w,h)~=true then 456 | local corner=only_one_corner(pts[2],p[2],x0,y0,w,h) 457 | if corner then 458 | pts[#pts+1]=corner 459 | else--补上两个角 460 | local tmp1,tmp2=on_rect_edge(pts[2],x0,y0,w,h) 461 | o1=pt_orientation(pts[1][1],pts[1][2],pts[2][1],pts[2][2],cp[1],cp[2]) 462 | o2=pt_orientation(pts[1][1],pts[1][2],pts[2][1],pts[2][2],tmp1[1],tmp1[2]) 463 | if o1==o2 then pts[3]=tmp1 else pts[3]=tmp2 end 464 | tmp1,tmp2=on_rect_edge(p[2],x0,y0,w,h) 465 | if tmp1[1]==pts[3][1] or tmp1[2]==pts[3][2] then 466 | pts[4]=tmp1 467 | else pts[4]=tmp2 468 | end 469 | end 470 | end 471 | pts[#pts+1]=p[2] pts[#pts+1]=p[1] pts=add_corner(pts,cp,x0,y0,w,h) 472 | end 473 | return pts 474 | end 475 | 476 | local function one_tri_and_circ_inside_the_rect(edges,cp,cir,x0,y0,w,h) 477 | local e1,e2=edges[1],edges[2] local cell,pts 478 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 479 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 480 | local mid1,mid2={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2},{(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 481 | if cir.x==mid1[1] and cir.y==mid1[2] then--外心在edge[1]这条边上 482 | local new={mid1[1]+cp[2]-e1[2],mid1[2]+e1[1]-cp[1]} 483 | local o3=pt_orientation(e1[1],e1[2],cp[1],cp[2],new[1],new[2]) 484 | if o2~=o3 then new={mid1[1]+e1[2]-cp[2],mid1[2]+cp[1]-e1[1]} end 485 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) pts[2]=mid1 486 | local p=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]=p[1] 487 | pts=add_corner(pts,cp,x0,y0,w,h) 488 | return pts 489 | elseif cir.x==mid2[1] and cir.y==mid2[2] then 490 | local new={mid2[1]+cp[2]-e2[2],mid2[2]+e2[1]-cp[1]} 491 | local o3=pt_orientation(e2[1],e2[2],cp[1],cp[2],new[1],new[2]) 492 | if o1~=o3 then new={mid2[1]+e2[2]-cp[2],mid2[2]+cp[1]-e2[1]} end 493 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) pts[2]=mid2 494 | local p=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]=p[1] 495 | pts=add_corner(pts,cp,x0,y0,w,h) 496 | return pts 497 | end 498 | if o1==o2 then--说明外心不在两条边的同一侧,所以一条射线是其边中点指向外心,另一条射线是外心指向其边中点 499 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 500 | if o1~=o3 then--那么针对第一条边的射线是从外心指向第一边中点,针对第二条边则相反 501 | cell=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 502 | pts=rect_ray_intersection({mid2,{cir.x,cir.y}},x0,y0,w,h) 503 | else 504 | cell=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 505 | pts=rect_ray_intersection({mid1,{cir.x,cir.y}},x0,y0,w,h) 506 | end 507 | else 508 | cell=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 509 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 510 | end 511 | cell[2]={cir.x,cir.y} cell[3]=pts[1] cell=add_corner(cell,cp,x0,y0,w,h) 512 | return cell 513 | end 514 | 515 | local function first_tri_and_circ_inside_the_rect(edges,cp,cir,next,x0,y0,w,h) 516 | local e1,e2=edges[1],edges[2] local pts 517 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 518 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 519 | local mid1={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2} 520 | if cir.x==mid1[1] and cir.y==mid1[2] then--外心在edge[1]这条边上 521 | local new={mid1[1]+cp[2]-e1[2],mid1[2]+e1[1]-cp[1]} 522 | local o3=pt_orientation(e1[1],e1[2],cp[1],cp[2],new[1],new[2]) 523 | if o2~=o3 then new={mid1[1]+e1[2]-cp[2],mid1[2]+cp[1]-e1[1]} end 524 | pts=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 525 | end 526 | if o1==o2 then--此时外心在三角形外 527 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 528 | if o1~=o3 then--则射线方向是从外心到第一条边中点 529 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 530 | else 531 | pts=rect_ray_intersection({mid1,{cir.x,cir.y}},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 532 | end 533 | else 534 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h)--射线方向是外心到第一边中点 535 | pts[#pts+1]={cir.x,cir.y} 536 | end 537 | if next.xx0+w or next.yy0+h then--下一个外心又在矩形外 538 | local p=rect_ray_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) pts[#pts+1]=p[1] 539 | else 540 | pts[#pts+1]={next.x,next.y} 541 | end 542 | return pts 543 | end 544 | 545 | local function first_tri_and_circ_outside_the_rect(edges,cp,cir,next,x0,y0,w,h) 546 | local e1,e2=edges[1],edges[2] local pts={} 547 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 548 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 549 | local mid1={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2} 550 | if o1==o2 then 551 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 552 | if o1~=o3 then--外心在第二边外侧,射线方向是从外心到第一条边中点 553 | local p=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 554 | pts[1]=p[2] pts[2]=p[1] 555 | end 556 | else 557 | local p=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 558 | pts[1]=p[2] pts[2]=p[1] 559 | end 560 | if next.xx0+w or next.yy0+h then--下一个外心又在矩形外 561 | local p=rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 562 | if p[1] then 563 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 564 | end 565 | else 566 | local p=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 567 | if pts[1] and (on_the_same_edge(pts[#pts],p[1],x0,y0,w,h)~=true) then 568 | local corner=only_one_corner(pts[#pts],p[1],x0,y0,w,h) pts[#pts+1]=corner 569 | end 570 | pts[#pts+1]=p[1] pts[#pts+1]={next.x,next.y} 571 | end 572 | return pts 573 | end 574 | 575 | local function last_tri_and_circ_outside_the_rect(edges,cp,cir,x0,y0,w,h)--外心在矩形外,外心必然不在三角形边上 576 | local e1,e2=edges[#edges-1],edges[#edges] local pts={} 577 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 578 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 579 | local mid2={(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 580 | if o1==o2 then 581 | local o3=pt_orientation(e2[1],e2[2],e1[1],e1[2],cir.x,cir.y) 582 | if o1~=o3 then--外心在倒数第二边外侧,射线方向是从外心到最后一条边中点 583 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 584 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 585 | end 586 | else 587 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 588 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 589 | end 590 | return pts 591 | end 592 | 593 | local function last_tri_and_circ_inside_the_rect(edges,cp,cir,x0,y0,w,h) 594 | local e1,e2=edges[#edges-1],edges[#edges] local pts 595 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 596 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 597 | local mid2={(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 598 | if cir.x==mid2[1] and cir.y==mid2[2] then--外心在最后一条边上 599 | local new={mid2[1]+cp[2]-e2[2],mid2[2]+e2[1]-cp[1]} 600 | local o3=pt_orientation(e2[1],e2[2],cp[1],cp[2],new[1],new[2]) 601 | if o1~=o3 then new={mid2[1]+e2[2]-cp[2],mid2[2]+cp[1]-e2[1]} end 602 | pts=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) 603 | return pts 604 | end 605 | if o1==o2 then--外心在三角形外 606 | local o3=pt_orientation(e2[1],e2[2],e1[1],e1[2],cir.x,cir.y) 607 | if o1==o3 then--则外心在最后一条边外侧,射线方向是从最后一条边中点到外心 608 | pts=rect_ray_intersection({mid2,{cir.x,cir.y}},x0,y0,w,h) 609 | else 610 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 611 | end 612 | else 613 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 614 | end 615 | return pts 616 | end 617 | 618 | local function except_the_first_and_last(cir,next,x0,y0,w,h)--讨论既不是第一个也不是最后一个tri的情况(neither first nor last) 619 | if next.xx0+w or next.yy0+h then--下一个外心在矩形外 620 | if cir.xx0+w or cir.yy0+h then 621 | return rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 622 | else return rect_ray_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 623 | end 624 | else 625 | if cir.xx0+w or cir.yy0+h then 626 | local pts=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 627 | pts[#pts+1]={next.x,next.y} 628 | return pts 629 | else return {{next.x,next.y}} 630 | end 631 | end 632 | end 633 | 634 | local function normal_tri(cir,next,x0,y0,w,h)--当该组三角形里没有在边缘的三角形时。每次添加一条线段,即该函数要不然返回空表,要不然返回有两个点的表 635 | if next.xx0+w or next.yy0+h then--下一个外心在矩形外 636 | if cir.xx0+w or cir.yy0+h then 637 | return rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 638 | else 639 | local pts,p={{cir.x,cir.y}},rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 640 | pts[2]=p[1] return pts 641 | end 642 | else--下一个外心在矩形内时 643 | if cir.xx0+w or cir.yy0+h then 644 | local pts=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 645 | pts[#pts+1]={next.x,next.y} 646 | return pts 647 | else--此时的外心和下一个外心都在矩形内 648 | if cir.x==next.x and cir.y==next.y then--当下一个外心和此时的外心是同一个点时,没必要再把下一个外心的坐标加进去了 649 | return {} 650 | else return {{cir.x,cir.y},{next.x,next.y}} 651 | end 652 | end 653 | end 654 | end 655 | 656 | function voronoi_cell(final_tri,p,x0,y0,w,h) 657 | local collect={} local x1,y1,x2,y2=x0,y0,x0+w,y0+h 658 | if #p==1 then 659 | return {{{x0,y0},{x0+w,y0},{x0+w,y0+h},{x0,y0+h}}} 660 | elseif #p==2 then 661 | local mid={(p[1][1]+p[2][1])/2,(p[1][2]+p[2][2])/2} local new={mid[1]+p[1][2]-p[2][2],mid[2]+p[2][1]-p[1][1]} 662 | local pts=rect_line_intersection({new,mid},x0,y0,w,h) 663 | local cell=add_corner({pts[1],pts[2]},p[1],x0,y0,w,h) local cell2=add_corner({pts[1],pts[2]},p[2],x0,y0,w,h) 664 | return {cell,cell2} 665 | end 666 | local flag={} 667 | for i=1,#final_tri do 668 | for i2=1,3 do 669 | local x,y=final_tri[i][i2][1],final_tri[i][i2][2] 670 | flag[x]=flag[x]==nil and {} or flag[x] flag[x][y]=flag[x][y]==nil and {} or flag[x][y] 671 | local len=#flag[x][y] flag[x][y][len+1]=final_tri[i] 672 | end 673 | end 674 | for i=1,#p do 675 | local temp,vor_cell,circum=flag[p[i][1]][p[i][2]],{},{} local edges 676 | temp,edges=tri_sort(temp,p[i])--temp装有以p[i]这个点为中心的一组三角形 677 | for i1=1,#temp do 678 | circum[i1]=circumcircle2(temp[i1]) 679 | end 680 | for i1=1,#temp do 681 | local cir=circum[i1] local idx=i1==#temp and 1 or i1+1 local next=circum[idx] 682 | if #temp==#edges then--该组三角形数量和edge数量一样,则该组三角形不在边界、边缘上(该组三角形没有边缘三角形) 683 | local pts=normal_tri(cir,next,x1,y1,x2-x1,y2-y1) 684 | if #vor_cell==0 then 685 | vor_cell=pts 686 | else 687 | if #pts>0 then 688 | if vor_cell[#vor_cell][1]==pts[1][1] and vor_cell[#vor_cell][2]==pts[1][2] then 689 | vor_cell[#vor_cell+1]=pts[2] 690 | else 691 | if on_the_same_edge(vor_cell[#vor_cell],pts[1],x0,y0,w,h)~=true then 692 | vor_cell[#vor_cell+1]=only_one_corner(vor_cell[#vor_cell],pts[1],x0,y0,w,h) 693 | end 694 | vor_cell[#vor_cell+1]=pts[1] vor_cell[#vor_cell+1]=pts[2] 695 | end 696 | end 697 | end 698 | if i1==#temp then 699 | if vor_cell[1] and on_the_same_edge(vor_cell[1],vor_cell[#vor_cell],x0,y0,w,h)~=true then 700 | local corner=only_one_corner(vor_cell[1],vor_cell[#vor_cell],x0,y0,w,h) 701 | if corner then 702 | vor_cell[#vor_cell+1]=corner 703 | end 704 | end 705 | end 706 | elseif #temp==1 then--该组三角形里只有一个三角形时 707 | if cir.xx2 or cir.yy2 then 708 | vor_cell=one_tri_and_circ_outside_the_rect(edges,p[i],cir,x0,y0,w,h) 709 | else vor_cell=one_tri_and_circ_inside_the_rect(edges,p[i],cir,x0,y0,w,h) 710 | end 711 | else--该组三角形有边缘三角形、即第一个和最后一个三角形是在边缘的,与它们相邻的三角形只有一个 712 | if i1==1 then 713 | if cir.xx2 or cir.yy2 then 714 | vor_cell=first_tri_and_circ_outside_the_rect(edges,p[i],cir,next,x1,y1,x2-x1,y2-y1) 715 | else 716 | vor_cell=first_tri_and_circ_inside_the_rect(edges,p[i],cir,next,x1,y1,x2-x1,y2-y1) 717 | end 718 | elseif i1==#temp then 719 | if cir.xx2 or cir.yy2 then 720 | local pts=last_tri_and_circ_outside_the_rect(edges,p[i],cir,x1,y1,x2-x1,y2-y1) 721 | if pts[1] then 722 | if vor_cell[1] and (on_the_same_edge(vor_cell[#vor_cell],pts[1],x0,y0,w,h)~=true) then 723 | vor_cell[#vor_cell+1]=only_one_corner(vor_cell[#vor_cell],pts[1],x0,y0,w,h) 724 | end 725 | for ip=1,#pts do 726 | vor_cell[#vor_cell+1]=pts[ip] 727 | end 728 | end 729 | else 730 | local pts=last_tri_and_circ_inside_the_rect(edges,p[i],cir,x1,y1,x2-x1,y2-y1) 731 | vor_cell[#vor_cell+1]=pts[1] 732 | end 733 | vor_cell=add_corner(vor_cell,p[i],x0,y0,w,h) 734 | else 735 | local pts=except_the_first_and_last(cir,next,x1,y1,w,h) 736 | for ip=1,#pts do 737 | vor_cell[#vor_cell+1]=pts[ip] 738 | end 739 | end 740 | end 741 | end 742 | collect[#collect+1]=vor_cell 743 | end 744 | return collect 745 | end 746 | 747 | local function to_draw(points,dx,dy) 748 | local s={} local dx=dx or 0 local dy=dy or 0 749 | for i=1,#points do 750 | s[#s+1]="l "..math_round(points[i][1]-dx,2).." "..math_round(points[i][2]-dy,2).." " 751 | end 752 | return table.concat(s):gsub("^l","m") 753 | end 754 | 755 | local function tri_center(tri) 756 | return {x=(tri[1][1]+tri[2][1]+tri[3][1])/3,y=(tri[1][2]+tri[2][2]+tri[3][2])/3} 757 | end 758 | 759 | local function poly_area(pt) 760 | local s=0 761 | for i=1,#pt do 762 | local idx=i==#pt and 1 or i+1 763 | s=s+pt[i][1]*pt[idx][2]-pt[i][2]*pt[idx][1] 764 | end 765 | return math.abs(s/2) 766 | end 767 | 768 | local function poly_center(pt) 769 | local x,y=0,0 770 | for i=1,#pt do 771 | x,y=x+pt[i][1],y+pt[i][2] 772 | end 773 | return x/#pt,y/#pt 774 | end 775 | 776 | function polyc.reset_pts_idx(pts) 777 | local new={} 778 | for i=1,#pts do 779 | if pts[i].x then 780 | new[i]={pts[i].x,pts[i].y} 781 | else 782 | new[i]={x=pts[i][1],y=pts[i][2]} 783 | end 784 | end 785 | return new 786 | end 787 | 788 | function polyc.delaunay(p,sup) 789 | local sup=sup or {{-1000000,1000000},{0,-1000000},{1000000,1000000}} 790 | local final_tri=tin(p,sup) local s={} 791 | for i=1,#final_tri do 792 | local c=tri_center(final_tri[i]) 793 | s[i]={s=to_draw(final_tri[i],c.x,c.y),x=math_round(c.x,1),y=math_round(c.y,1)} 794 | end 795 | return s 796 | end 797 | 798 | function polyc.voronoi(p,x0,y0,w,h) 799 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 800 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local s={} 801 | local final_tri,p=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 802 | for i=1,#vor_cell do 803 | s[i]={s=to_draw(vor_cell[i],p[i][1],p[i][2]),x=math_round(p[i][1],1),y=math_round(p[i][2],1)} 804 | end 805 | return s 806 | end 807 | 808 | function polyc.tin_and_vor(p,x0,y0,w,h) 809 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 810 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local tri,vor={},{} 811 | local final_tri=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 812 | for i=1,#final_tri do 813 | local c=tri_center(final_tri[i]) 814 | tri[i]={s=to_draw(final_tri[i],c.x,c.y),x=math_round(c.x,1),y=math_round(c.y,1)} 815 | end 816 | for i=1,#vor_cell do 817 | vor[i]={s=to_draw(vor_cell[i],p[i][1],p[i][2]),x=math_round(p[i][1],1),y=math_round(p[i][2],1)} 818 | end 819 | return tri,vor 820 | end 821 | 822 | function polyc.vor_vortex(p,x0,y0,w,h,pct,n,area) 823 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 824 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local s,poly={n={}},{} 825 | local final_tri,p=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 826 | for i=1,#vor_cell do 827 | poly[i]={vor_cell[i]} local cnt=poly_area(vor_cell[i]) local cx,cy=poly_center(vor_cell[i]) 828 | s[i]={{s=to_draw(vor_cell[i],cx,cy),x=math_round(cx,1),y=math_round(cy,1)}} 829 | if not area then 830 | for i2=1,n do 831 | poly[i][i2+1]={} 832 | for i3=1,#vor_cell[i] do 833 | local idx=i3==#vor_cell[i] and 1 or i3+1 local x=(poly[i][i2][idx][1]-poly[i][i2][i3][1])*pct+poly[i][i2][i3][1] 834 | local y=(poly[i][i2][idx][2]-poly[i][i2][i3][2])*pct+poly[i][i2][i3][2] poly[i][i2+1][i3]={x,y} 835 | end 836 | s[i][i2+1]={s=to_draw(poly[i][i2+1],cx,cy),x=math_round(cx,1),y=math_round(cy,1)} 837 | end 838 | else 839 | while cnt>area do 840 | local num=#poly[i] poly[i][num+1]={} 841 | for i2=1,#vor_cell[i] do 842 | local idx=i2==#vor_cell[i] and 1 or i2+1 local x=(poly[i][num][idx][1]-poly[i][num][i2][1])*pct+poly[i][num][i2][1] 843 | local y=(poly[i][num][idx][2]-poly[i][num][i2][2])*pct+poly[i][num][i2][2] poly[i][num+1][i2]={x,y} 844 | end 845 | cnt=poly_area(poly[i][num+1]) 846 | s[i][num+1]={s=to_draw(poly[i][num+1],cx,cy),x=math_round(cx,1),y=math_round(cy,1)} 847 | end 848 | end 849 | s.n[i]=#s[i] 850 | end 851 | return s,poly 852 | end 853 | 854 | 855 | local polyb=require 'polyb' 856 | 857 | polyc.vor_shatter=polyb.vor_shatter 858 | 859 | polyc.vor_shatter2=polyb.vor_shatter2 860 | 861 | polyc.rect_vor_shatter=polyb.rect_vor_shatter 862 | 863 | polyc.circle_vor_shatter=polyb.circle_vor_shatter 864 | 865 | polyc.tin_shatter=polyb.tin_shatter 866 | 867 | 868 | function polyc.voronoi_move(frames,n,points_n,x0,y0,w,h) 869 | local p={} local each=math.ceil(frames/n) local s={n={{points_n,each*(n-1)}}} 870 | for i=1,n do 871 | p[i]=polyc.rand_coor(points_n,x0,y0,w,h) 872 | end 873 | for i=1,n-1 do 874 | for i1=1,each do 875 | local points={} 876 | for i2=1,points_n do 877 | points[i2]={(p[i+1][i2][1]-p[i][i2][1])*(i1-1)/(each-1)+p[i][i2][1],(p[i+1][i2][2]-p[i][i2][2])*(i1-1)/(each-1)+p[i][i2][2]} 878 | end 879 | s[#s+1]=polyc.voronoi(points,x0,y0,w,h) 880 | end 881 | end 882 | return s 883 | end 884 | 885 | 886 | _G.polyc=polyc 887 | return _G.polyc -------------------------------------------------------------------------------- /多边形库/polyc.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | --自己瞎写的破烂函数库 4 | --我b站账号:https://space.bilibili.com/346816900 5 | --Aegisub视频整合:https://space.bilibili.com/346816900/channel/seriesdetail?sid=231885 6 | --如果没有polyb,请注释掉第852到第862行。(以后我会发出相应的文件,可以留意一下更新) 7 | --转载请注明作者和出处! 8 | 9 | local polyc={} 10 | 11 | local function math_round(n,digit) 12 | if digit and digit>=1 then 13 | digit=10^math.floor(digit) 14 | return math.floor(n*digit+0.5)/digit 15 | else return math.floor(n+0.5) 16 | end 17 | end 18 | 19 | function polyc.rand_coor(n,x0,y0,w,h) 20 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 21 | for i=1,n do 22 | coor[i]={x0+w*(i-1)/n+w/n*math.random(),y0+h*math.random()} 23 | end 24 | return coor,sup 25 | end 26 | 27 | function polyc.rand_coor2(n,n2,x0,y0,w,h) 28 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 29 | for i=1,n do 30 | for i1=1,n2 do 31 | local x=x0+w*(i-1)/n+w/n*math.random() 32 | local y=y0+h*(i1-1)/n2+h/n2*math.random() 33 | coor[#coor+1]={x,y} 34 | end 35 | end 36 | return coor,sup 37 | end 38 | 39 | function polyc.rand_coor_rect(n,n2,x0,y0,w,h) 40 | local coor={} local sup={{x0-w*10,y0+h*10},{x0+20*w,y0+h*10},{x0+w/2,y0-math.max(w,h)*10}} 41 | for i=1,n do 42 | for i1=1,n2 do 43 | local x=i==1 and x0 or (i==n and x0+w or x0+w*(i-1)/n+w/n*math.random()) 44 | local y=i1==1 and y0 or (i1==n2 and y0+h or y0+h*(i1-1)/n2+h/n2*math.random()) 45 | coor[#coor+1]={x,y} 46 | end 47 | end 48 | return coor,sup 49 | end 50 | 51 | function polyc.rand_coor_circle(n,n2,x0,y0,R)--园内n个点,圆上n2个点 52 | local coor={} local sup={{x0-R*10,y0+R*10},{x0+20*R,y0+R*10},{x0+R/2,y0-R*10}} 53 | local deg=math.rad(360/n2) 54 | for i=1,n do 55 | local x=x0-R/2+R*(i-1)/n+R/n*math.random() local y=((R/2)^2-(x-x0)^2)^0.5 y=y0+math.random(-y,y) 56 | coor[i]={x,y} 57 | end 58 | for i=1,n2 do 59 | local d=deg*math.random() 60 | coor[n+i]={x0+R/2*math.cos((i-1)*deg+d),y0+R/2*math.sin((i-1)*deg+d)} 61 | end 62 | return coor,sup 63 | end 64 | 65 | local function circumcircle(tri) 66 | local x1,y1=tri[1][1],tri[1][2] local x2,y2=tri[2][1],tri[2][2] local x3,y3=tri[3][1],tri[3][2] 67 | local x=((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2*(x3-x1)*(y2-y1)-2*((x2-x1)*(y3-y1))) 68 | local y=((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2*(y3-y1)*(x2-x1)-2*((y2-y1)*(x3-x1))) 69 | local r=((x-x1)^2+(y-y1)^2)^0.5 local cir={x=x,y=y,r=r} 70 | return cir 71 | end 72 | 73 | local function circumcircle2(tri)--只计算外接圆圆心 74 | local x1,y1=tri[1][1],tri[1][2] local x2,y2=tri[2][1],tri[2][2] local x3,y3=tri[3][1],tri[3][2] 75 | local x=((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2*(x3-x1)*(y2-y1)-2*((x2-x1)*(y3-y1))) 76 | local y=((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2*(y3-y1)*(x2-x1)-2*((y2-y1)*(x3-x1))) 77 | return {x=x,y=y} 78 | end 79 | 80 | local function check_p(tri,p) 81 | local cir=circumcircle(tri) 82 | if (p[1]-cir.x)^2+(p[2]-cir.y)^21 then return true end 186 | end 187 | end 188 | return false 189 | end 190 | 191 | local function tri_sort(tris,p) 192 | local function get_coor(tri,p1,p2) 193 | for i=1,3 do 194 | if check({tri[i]},p1)==false and check({tri[i]},p2)==false then 195 | return tri[i] 196 | end 197 | end 198 | end 199 | local point local sort,edges={},{} 200 | for i=1,#tris do 201 | for i1=1,3 do 202 | if tris_include_p(tris,tris[i][i1])==false and check({tris[i][i1]},p)==false then 203 | sort[#sort+1]=tris[i] point=tris[i][i1] edges[#edges+1]=point 204 | point=get_coor(tris[i],p,point) edges[#edges+1]=point table.remove(tris,i) break 205 | end 206 | end 207 | if #sort>0 then break end 208 | end 209 | if #sort==0 then 210 | for i=1,#tris[1] do 211 | if tris[1][i][1]~=p[1] or tris[1][i][2]~=p[2] then 212 | sort[1]=tris[1] point=tris[1][i] edges[1]=point table.remove(tris,1) break 213 | end 214 | end 215 | end 216 | for _=1,#tris do 217 | for i=#tris,1,-1 do 218 | if check(tris[i],point) then 219 | sort[#sort+1]=tris[i] point=get_coor(tris[i],p,point) edges[#edges+1]=point 220 | table.remove(tris,i) break 221 | end 222 | end 223 | end 224 | return sort,edges 225 | end 226 | 227 | local function h_line_seg_isect(x1,y1,x2,y2,y)--水平线和线段交点 228 | local top,bottom=math.min(y1,y2),math.max(y1,y2) 229 | if y>=top and y<=bottom then 230 | return x1+((x2-x1)/(y2-y1))*(y-y1) 231 | end 232 | end 233 | 234 | local function h_line_isect(x1,y1,x2,y2,y)--水平线和直线交点 235 | return x1+((x2-x1)/(y2-y1))*(y-y1) 236 | end 237 | 238 | local function v_line_isect(x1,y1,x2,y2,x)--竖直线和直线交点 239 | return y1+((y2-y1)/(x2-x1))*(x-x1) 240 | end 241 | 242 | local function v_line_seg_isect(x1,y1,x2,y2,x)--竖直线和线段交点 243 | local left,right=math.min(x1,x2),math.max(x1,x2) 244 | if x>=left and x<=right then 245 | return y1+((y2-y1)/(x2-x1))*(x-x1) 246 | end 247 | end 248 | 249 | local function sgn(n) 250 | return n>0 and 1 or n<0 and -1 or 0 251 | end 252 | 253 | local function rect_seg_intersection(seg,x0,y0,w,h) 254 | local p={} 255 | local x1=h_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],y0) 256 | local x2=h_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],y0+h) 257 | local y1=v_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],x0) 258 | local y2=v_line_seg_isect(seg[1][1],seg[1][2],seg[2][1],seg[2][2],x0+w) 259 | if x1 and x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2 and x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 261 | if #p==2 then 262 | local dx,dy,dx1,dy1=seg[2][1]-seg[1][1],seg[2][2]-seg[1][2],p[2][1]-p[1][1],p[2][2]-p[1][2] 263 | if math.abs(dx)>1 then 264 | if sgn(dx)~=sgn(dx1) then p={p[2],p[1]} end 265 | else 266 | if math.abs(dy)>1 then 267 | if sgn(dy)~=sgn(dy1) then p={p[2],p[1]} end 268 | else 269 | if sgn(dx)~=sgn(dx1) or sgn(dy)~=sgn(dy1) then 270 | p={p[2],p[1]} 271 | end 272 | end 273 | end 274 | end 275 | return p 276 | end 277 | 278 | local function rect_ray_intersection(ray,x0,y0,w,h) 279 | local p,insect,dx,dy={},{},ray[2][1]-ray[1][1],ray[2][2]-ray[1][2] 280 | local x1=h_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],y0) 281 | local x2=h_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],y0+h) 282 | local y1=v_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],x0) 283 | local y2=v_line_isect(ray[1][1],ray[1][2],ray[2][1],ray[2][2],x0+w) 284 | if x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 286 | for i=1,#p do 287 | if math.abs(dx)>1 then 288 | local dx1=p[i][1]-ray[1][1] 289 | if sgn(dx)==sgn(dx1) then insect[#insect+1]=p[i] end 290 | else 291 | if math.abs(dy)>1 then 292 | local dy1=p[i][2]-ray[1][2] 293 | if sgn(dy)==sgn(dy1) then insect[#insect+1]=p[i] end 294 | else 295 | local dx1,dy1=p[i][1]-ray[1][1],p[i][2]-ray[1][2] 296 | if sgn(dx)==sgn(dx1) and sgn(dy)==sgn(dy1) then 297 | insect[#insect+1]=p[i] 298 | end 299 | end 300 | end 301 | if p[i][1]==ray[1][1] and p[i][2]==ray[1][2] then--如果矩形和射线的交点刚好是射线的端点 302 | insect[#insect+1]=p[i] 303 | end 304 | end 305 | if #insect==2 then 306 | local dx1,dy1=insect[2][1]-insect[1][1],insect[2][2]-insect[1][2] 307 | if math.abs(dx)>1 then 308 | if sgn(dx)~=sgn(dx1) then insect={insect[2],insect[1]} end 309 | else 310 | if math.abs(dy)>1 then 311 | if sgn(dy)~=sgn(dy1) then insect={insect[2],insect[1]} end 312 | else 313 | if sgn(dx)~=sgn(dx1) or sgn(dy)~=sgn(dy1) then 314 | insect={insect[2],insect[1]} 315 | end 316 | end 317 | end 318 | end 319 | return insect 320 | end 321 | 322 | local function rect_line_intersection(line,x0,y0,w,h) 323 | local p={} 324 | local x1=h_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],y0) 325 | local x2=h_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],y0+h) 326 | local y1=v_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],x0) 327 | local y2=v_line_isect(line[1][1],line[1][2],line[2][1],line[2][2],x0+w) 328 | if x1>x0 and x1<=x0+w then p[#p+1]={x1,y0} end if x2>=x0 and x2=y0 and y1y0 and y2<=y0+h then p[#p+1]={x0+w,y2} end--防止端点重复添加 330 | return p 331 | end 332 | 333 | local function pt_orientation(p_x,p_y,q_x,q_y,r_x,r_y) 334 | local o=(q_y-p_y)*(r_x-q_x)-(q_x-p_x)*(r_y-q_y) if math.abs(o)<1e-9 then return 0 end 335 | return o>0 and 1 or o<0 and -1 or 0 336 | end 337 | 338 | local function on_rect_edge(p,x0,y0,w,h)--p点处于矩形哪一条边上 339 | if p[1]==x0 then 340 | return {x0,y0},{x0,y0+h} 341 | elseif p[1]==x0+w then 342 | return {x0+w,y0},{x0+w,y0+h} 343 | elseif p[2]==y0 then 344 | return {x0,y0},{x0+w,y0} 345 | elseif p[2]==y0+h then 346 | return {x0,y0+h},{x0+w,y0+h} 347 | end 348 | end 349 | 350 | local function only_one_corner(p1,p2,x0,y0,w,h) 351 | local p1x,p1y,p2x,p2y=p1[1],p1[2],p2[1],p2[2] 352 | if p1x==x0 and p2x~=x0 and p2x~=x0+w then 353 | if p2y==y0 then 354 | return {x0,y0} 355 | end 356 | if p2y==y0+h then 357 | return {x0,y0+h} 358 | end 359 | end 360 | if p1x==x0+w and p2x~=x0+w and p2x~=x0 then 361 | if p2y==y0 then 362 | return {x0+w,y0} 363 | end 364 | if p2y==y0+h then 365 | return {x0+w,y0+h} 366 | end 367 | end 368 | if p2x==x0 and p1x~=x0 and p1x~=x0+w then 369 | if p1y==y0 then 370 | return {x0,y0} 371 | end 372 | if p1y==y0+h then 373 | return {x0,y0+h} 374 | end 375 | end 376 | if p2x==x0+w and p1x~=x0+w and p1x~=x0 then 377 | if p1y==y0 then 378 | return {x0+w,y0} 379 | end 380 | if p1y==y0+h then 381 | return {x0+w,y0+h} 382 | end 383 | end 384 | end 385 | 386 | local function on_the_same_edge(p1,p2,x0,y0,w,h)--p1、p2两点在矩形的同一条边上 387 | local p1x,p1y,p2x,p2y=p1[1],p1[2],p2[1],p2[2] 388 | if p1x==x0 and p2x==x0 then return true end if p1x==x0+w and p2x==x0+w then return true end 389 | if p1y==y0 and p2y==y0 then return true end if p1y==y0+h and p2y==y0+h then return true end 390 | end 391 | 392 | local function add_corner(cell,p,x0,y0,w,h) 393 | local first,last=cell[1],cell[#cell] 394 | if on_the_same_edge(first,last,x0,y0,w,h)~=true then 395 | local corner=only_one_corner(first,last,x0,y0,w,h) 396 | if corner then 397 | local o1=pt_orientation(first[1],first[2],cell[2][1],cell[2][2],p[1],p[2]) 398 | local o2=pt_orientation(corner[1],corner[2],first[1],first[2],cell[2][1],cell[2][2]) 399 | if o1==o2 then--只添加一个角落 400 | cell[#cell+1]=corner 401 | else--需要添加三个角 402 | local tmp1,tmp2=on_rect_edge(last,x0,y0,w,h) 403 | if tmp1[1]==corner[1] and tmp1[2]==corner[2] then 404 | cell[#cell+1]=tmp2 405 | else cell[#cell+1]=tmp1 406 | end 407 | if corner[1]==cell[#cell][1] then 408 | if cell[#cell][1]==x0 then 409 | cell[#cell+1]={x0+w,cell[#cell][2]} 410 | else cell[#cell+1]={x0,cell[#cell][2]} 411 | end 412 | else 413 | if cell[#cell][2]==y0 then 414 | cell[#cell+1]={cell[#cell][1],y0+h} 415 | else cell[#cell+1]={cell[#cell][1],y0} 416 | end 417 | end 418 | tmp1,tmp2=on_rect_edge(first,x0,y0,w,h) 419 | if tmp1[1]==corner[1] and tmp1[2]==corner[2] then 420 | cell[#cell+1]=tmp2 421 | else cell[#cell+1]=tmp1 422 | end 423 | end 424 | else--需要添加两个角 425 | local tmp1,tmp2=on_rect_edge(last,x0,y0,w,h) 426 | local o1=pt_orientation(first[1],first[2],cell[2][1],cell[2][2],p[1],p[2]) 427 | local o2=pt_orientation(cell[#cell-1][1],cell[#cell-1][2],last[1],last[2],tmp1[1],tmp1[2]) 428 | if o1==o2 then cell[#cell+1]=tmp1 else cell[#cell+1]=tmp2 end 429 | tmp1,tmp2=on_rect_edge(first,x0,y0,w,h) 430 | if tmp1[1]==cell[#cell][1] or tmp1[2]==cell[#cell][2] then 431 | cell[#cell+1]=tmp1 432 | else cell[#cell+1]=tmp2 433 | end 434 | end 435 | end 436 | return cell 437 | end 438 | 439 | local function one_tri_and_circ_outside_the_rect(edges,cp,cir,x0,y0,w,h) 440 | local e1,e2=edges[1],edges[2] local pts 441 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 442 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 443 | local mid1,mid2={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2},{(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 444 | if o1==o2 then--说明外心不在两条边的同一侧,所以算射线和矩形交点时只需要其中一条边,另一条边忽略 445 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 446 | if o1~=o3 then--那么edge[1]就是需要的边,第二条边edge[2]用不上了 447 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 448 | else 449 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 450 | end 451 | pts=add_corner(pts,cp,x0,y0,w,h) 452 | else 453 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 454 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 455 | if on_the_same_edge(pts[2],p[2],x0,y0,w,h)~=true then 456 | local corner=only_one_corner(pts[2],p[2],x0,y0,w,h) 457 | if corner then 458 | pts[#pts+1]=corner 459 | else--补上两个角 460 | local tmp1,tmp2=on_rect_edge(pts[2],x0,y0,w,h) 461 | o1=pt_orientation(pts[1][1],pts[1][2],pts[2][1],pts[2][2],cp[1],cp[2]) 462 | o2=pt_orientation(pts[1][1],pts[1][2],pts[2][1],pts[2][2],tmp1[1],tmp1[2]) 463 | if o1==o2 then pts[3]=tmp1 else pts[3]=tmp2 end 464 | tmp1,tmp2=on_rect_edge(p[2],x0,y0,w,h) 465 | if tmp1[1]==pts[3][1] or tmp1[2]==pts[3][2] then 466 | pts[4]=tmp1 467 | else pts[4]=tmp2 468 | end 469 | end 470 | end 471 | pts[#pts+1]=p[2] pts[#pts+1]=p[1] pts=add_corner(pts,cp,x0,y0,w,h) 472 | end 473 | return pts 474 | end 475 | 476 | local function one_tri_and_circ_inside_the_rect(edges,cp,cir,x0,y0,w,h) 477 | local e1,e2=edges[1],edges[2] local cell,pts 478 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 479 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 480 | local mid1,mid2={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2},{(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 481 | if cir.x==mid1[1] and cir.y==mid1[2] then--外心在edge[1]这条边上 482 | local new={mid1[1]+cp[2]-e1[2],mid1[2]+e1[1]-cp[1]} 483 | local o3=pt_orientation(e1[1],e1[2],cp[1],cp[2],new[1],new[2]) 484 | if o2~=o3 then new={mid1[1]+e1[2]-cp[2],mid1[2]+cp[1]-e1[1]} end 485 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) pts[2]=mid1 486 | local p=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]=p[1] 487 | pts=add_corner(pts,cp,x0,y0,w,h) 488 | return pts 489 | elseif cir.x==mid2[1] and cir.y==mid2[2] then 490 | local new={mid2[1]+cp[2]-e2[2],mid2[2]+e2[1]-cp[1]} 491 | local o3=pt_orientation(e2[1],e2[2],cp[1],cp[2],new[1],new[2]) 492 | if o1~=o3 then new={mid2[1]+e2[2]-cp[2],mid2[2]+cp[1]-e2[1]} end 493 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) pts[2]=mid2 494 | local p=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]=p[1] 495 | pts=add_corner(pts,cp,x0,y0,w,h) 496 | return pts 497 | end 498 | if o1==o2 then--说明外心不在两条边的同一侧,所以一条射线是其边中点指向外心,另一条射线是外心指向其边中点 499 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 500 | if o1~=o3 then--那么针对第一条边的射线是从外心指向第一边中点,针对第二条边则相反 501 | cell=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 502 | pts=rect_ray_intersection({mid2,{cir.x,cir.y}},x0,y0,w,h) 503 | else 504 | cell=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 505 | pts=rect_ray_intersection({mid1,{cir.x,cir.y}},x0,y0,w,h) 506 | end 507 | else 508 | cell=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 509 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 510 | end 511 | cell[2]={cir.x,cir.y} cell[3]=pts[1] cell=add_corner(cell,cp,x0,y0,w,h) 512 | return cell 513 | end 514 | 515 | local function first_tri_and_circ_inside_the_rect(edges,cp,cir,next,x0,y0,w,h) 516 | local e1,e2=edges[1],edges[2] local pts 517 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 518 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 519 | local mid1={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2} 520 | if cir.x==mid1[1] and cir.y==mid1[2] then--外心在edge[1]这条边上 521 | local new={mid1[1]+cp[2]-e1[2],mid1[2]+e1[1]-cp[1]} 522 | local o3=pt_orientation(e1[1],e1[2],cp[1],cp[2],new[1],new[2]) 523 | if o2~=o3 then new={mid1[1]+e1[2]-cp[2],mid1[2]+cp[1]-e1[1]} end 524 | pts=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 525 | end 526 | if o1==o2 then--此时外心在三角形外 527 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 528 | if o1~=o3 then--则射线方向是从外心到第一条边中点 529 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 530 | else 531 | pts=rect_ray_intersection({mid1,{cir.x,cir.y}},x0,y0,w,h) pts[#pts+1]={cir.x,cir.y} 532 | end 533 | else 534 | pts=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h)--射线方向是外心到第一边中点 535 | pts[#pts+1]={cir.x,cir.y} 536 | end 537 | if next.xx0+w or next.yy0+h then--下一个外心又在矩形外 538 | local p=rect_ray_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) pts[#pts+1]=p[1] 539 | else 540 | pts[#pts+1]={next.x,next.y} 541 | end 542 | return pts 543 | end 544 | 545 | local function first_tri_and_circ_outside_the_rect(edges,cp,cir,next,x0,y0,w,h) 546 | local e1,e2=edges[1],edges[2] local pts={} 547 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 548 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 549 | local mid1={(e1[1]+cp[1])/2,(e1[2]+cp[2])/2} 550 | if o1==o2 then 551 | local o3=pt_orientation(e1[1],e1[2],e2[1],e2[2],cir.x,cir.y) 552 | if o1~=o3 then--外心在第二边外侧,射线方向是从外心到第一条边中点 553 | local p=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 554 | pts[1]=p[2] pts[2]=p[1] 555 | end 556 | else 557 | local p=rect_ray_intersection({{cir.x,cir.y},mid1},x0,y0,w,h) 558 | pts[1]=p[2] pts[2]=p[1] 559 | end 560 | if next.xx0+w or next.yy0+h then--下一个外心又在矩形外 561 | local p=rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 562 | if p[1] then 563 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 564 | end 565 | else 566 | local p=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 567 | if pts[1] and (on_the_same_edge(pts[#pts],p[1],x0,y0,w,h)~=true) then 568 | local corner=only_one_corner(pts[#pts],p[1],x0,y0,w,h) pts[#pts+1]=corner 569 | end 570 | pts[#pts+1]=p[1] pts[#pts+1]={next.x,next.y} 571 | end 572 | return pts 573 | end 574 | 575 | local function last_tri_and_circ_outside_the_rect(edges,cp,cir,x0,y0,w,h)--外心在矩形外,外心必然不在三角形边上 576 | local e1,e2=edges[#edges-1],edges[#edges] local pts={} 577 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 578 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 579 | local mid2={(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 580 | if o1==o2 then 581 | local o3=pt_orientation(e2[1],e2[2],e1[1],e1[2],cir.x,cir.y) 582 | if o1~=o3 then--外心在倒数第二边外侧,射线方向是从外心到最后一条边中点 583 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 584 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 585 | end 586 | else 587 | local p=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 588 | pts[#pts+1]=p[1] pts[#pts+1]=p[2] 589 | end 590 | return pts 591 | end 592 | 593 | local function last_tri_and_circ_inside_the_rect(edges,cp,cir,x0,y0,w,h) 594 | local e1,e2=edges[#edges-1],edges[#edges] local pts 595 | local o1=pt_orientation(e1[1],e1[2],cp[1],cp[2],cir.x,cir.y) 596 | local o2=pt_orientation(e2[1],e2[2],cp[1],cp[2],cir.x,cir.y) 597 | local mid2={(e2[1]+cp[1])/2,(e2[2]+cp[2])/2} 598 | if cir.x==mid2[1] and cir.y==mid2[2] then--外心在最后一条边上 599 | local new={mid2[1]+cp[2]-e2[2],mid2[2]+e2[1]-cp[1]} 600 | local o3=pt_orientation(e2[1],e2[2],cp[1],cp[2],new[1],new[2]) 601 | if o1~=o3 then new={mid2[1]+e2[2]-cp[2],mid2[2]+cp[1]-e2[1]} end 602 | pts=rect_ray_intersection({{cir.x,cir.y},new},x0,y0,w,h) 603 | return pts 604 | end 605 | if o1==o2 then--外心在三角形外 606 | local o3=pt_orientation(e2[1],e2[2],e1[1],e1[2],cir.x,cir.y) 607 | if o1==o3 then--则外心在最后一条边外侧,射线方向是从最后一条边中点到外心 608 | pts=rect_ray_intersection({mid2,{cir.x,cir.y}},x0,y0,w,h) 609 | else 610 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 611 | end 612 | else 613 | pts=rect_ray_intersection({{cir.x,cir.y},mid2},x0,y0,w,h) 614 | end 615 | return pts 616 | end 617 | 618 | local function except_the_first_and_last(cir,next,x0,y0,w,h)--讨论既不是第一个也不是最后一个tri的情况(neither first nor last) 619 | if next.xx0+w or next.yy0+h then--下一个外心在矩形外 620 | if cir.xx0+w or cir.yy0+h then 621 | return rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 622 | else return rect_ray_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 623 | end 624 | else 625 | if cir.xx0+w or cir.yy0+h then 626 | local pts=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 627 | pts[#pts+1]={next.x,next.y} 628 | return pts 629 | else return {{next.x,next.y}} 630 | end 631 | end 632 | end 633 | 634 | local function normal_tri(cir,next,x0,y0,w,h)--当该组三角形里没有在边缘的三角形时。每次添加一条线段,即该函数要不然返回空表,要不然返回有两个点的表 635 | if next.xx0+w or next.yy0+h then--下一个外心在矩形外 636 | if cir.xx0+w or cir.yy0+h then 637 | return rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 638 | else 639 | local pts,p={{cir.x,cir.y}},rect_seg_intersection({{cir.x,cir.y},{next.x,next.y}},x0,y0,w,h) 640 | pts[2]=p[1] return pts 641 | end 642 | else--下一个外心在矩形内时 643 | if cir.xx0+w or cir.yy0+h then 644 | local pts=rect_seg_intersection({{next.x,next.y},{cir.x,cir.y}},x0,y0,w,h) 645 | pts[#pts+1]={next.x,next.y} 646 | return pts 647 | else--此时的外心和下一个外心都在矩形内 648 | if cir.x==next.x and cir.y==next.y then--当下一个外心和此时的外心是同一个点时,没必要再把下一个外心的坐标加进去了 649 | return {} 650 | else return {{cir.x,cir.y},{next.x,next.y}} 651 | end 652 | end 653 | end 654 | end 655 | 656 | function voronoi_cell(final_tri,p,x0,y0,w,h) 657 | local collect={} local x1,y1,x2,y2=x0,y0,x0+w,y0+h 658 | if #p==1 then 659 | return {{{x0,y0},{x0+w,y0},{x0+w,y0+h},{x0,y0+h}}} 660 | elseif #p==2 then 661 | local mid={(p[1][1]+p[2][1])/2,(p[1][2]+p[2][2])/2} local new={mid[1]+p[1][2]-p[2][2],mid[2]+p[2][1]-p[1][1]} 662 | local pts=rect_line_intersection({new,mid},x0,y0,w,h) 663 | local cell=add_corner({pts[1],pts[2]},p[1],x0,y0,w,h) local cell2=add_corner({pts[1],pts[2]},p[2],x0,y0,w,h) 664 | return {cell,cell2} 665 | end 666 | for i=1,#p do 667 | local temp,vor_cell,circum={},{},{} local edges 668 | for i1=1,#final_tri do 669 | if check(final_tri[i1],p[i]) then 670 | temp[#temp+1]=final_tri[i1] 671 | end 672 | end 673 | temp,edges=tri_sort(temp,p[i])--temp装有以p[i]这个点为中心的一组三角形 674 | for i1=1,#temp do 675 | circum[i1]=circumcircle2(temp[i1]) 676 | end 677 | for i1=1,#temp do 678 | local cir=circum[i1] local idx=i1==#temp and 1 or i1+1 local next=circum[idx] 679 | if #temp==#edges then--该组三角形数量和edge数量一样,则该组三角形不在边界、边缘上(该组三角形没有边缘三角形) 680 | local pts=normal_tri(cir,next,x1,y1,x2-x1,y2-y1) 681 | if #vor_cell==0 then 682 | vor_cell=pts 683 | else 684 | if #pts>0 then 685 | if vor_cell[#vor_cell][1]==pts[1][1] and vor_cell[#vor_cell][2]==pts[1][2] then 686 | vor_cell[#vor_cell+1]=pts[2] 687 | else 688 | if on_the_same_edge(vor_cell[#vor_cell],pts[1],x0,y0,w,h)~=true then 689 | vor_cell[#vor_cell+1]=only_one_corner(vor_cell[#vor_cell],pts[1],x0,y0,w,h) 690 | end 691 | vor_cell[#vor_cell+1]=pts[1] vor_cell[#vor_cell+1]=pts[2] 692 | end 693 | end 694 | end 695 | if i1==#temp then 696 | if vor_cell[1] and on_the_same_edge(vor_cell[1],vor_cell[#vor_cell],x0,y0,w,h)~=true then 697 | local corner=only_one_corner(vor_cell[1],vor_cell[#vor_cell],x0,y0,w,h) 698 | if corner then 699 | vor_cell[#vor_cell+1]=corner 700 | end 701 | end 702 | end 703 | elseif #temp==1 then--该组三角形里只有一个三角形时 704 | if cir.xx2 or cir.yy2 then 705 | vor_cell=one_tri_and_circ_outside_the_rect(edges,p[i],cir,x0,y0,w,h) 706 | else vor_cell=one_tri_and_circ_inside_the_rect(edges,p[i],cir,x0,y0,w,h) 707 | end 708 | else--该组三角形有边缘三角形、即第一个和最后一个三角形是在边缘的,与它们相邻的三角形只有一个 709 | if i1==1 then 710 | if cir.xx2 or cir.yy2 then 711 | vor_cell=first_tri_and_circ_outside_the_rect(edges,p[i],cir,next,x1,y1,x2-x1,y2-y1) 712 | else 713 | vor_cell=first_tri_and_circ_inside_the_rect(edges,p[i],cir,next,x1,y1,x2-x1,y2-y1) 714 | end 715 | elseif i1==#temp then 716 | if cir.xx2 or cir.yy2 then 717 | local pts=last_tri_and_circ_outside_the_rect(edges,p[i],cir,x1,y1,x2-x1,y2-y1) 718 | if pts[1] then 719 | if vor_cell[1] and (on_the_same_edge(vor_cell[#vor_cell],pts[1],x0,y0,w,h)~=true) then 720 | vor_cell[#vor_cell+1]=only_one_corner(vor_cell[#vor_cell],pts[1],x0,y0,w,h) 721 | end 722 | for ip=1,#pts do 723 | vor_cell[#vor_cell+1]=pts[ip] 724 | end 725 | end 726 | else 727 | local pts=last_tri_and_circ_inside_the_rect(edges,p[i],cir,x1,y1,x2-x1,y2-y1) 728 | vor_cell[#vor_cell+1]=pts[1] 729 | end 730 | vor_cell=add_corner(vor_cell,p[i],x0,y0,w,h) 731 | else 732 | local pts=except_the_first_and_last(cir,next,x1,y1,w,h) 733 | for ip=1,#pts do 734 | vor_cell[#vor_cell+1]=pts[ip] 735 | end 736 | end 737 | end 738 | end 739 | collect[#collect+1]=vor_cell 740 | end 741 | return collect 742 | end 743 | 744 | local function to_draw(points,dx,dy) 745 | local s={} local dx=dx or 0 local dy=dy or 0 746 | for i=1,#points do 747 | s[#s+1]="l "..math_round(points[i][1]-dx,2).." "..math_round(points[i][2]-dy,2).." " 748 | end 749 | return table.concat(s):gsub("^l","m") 750 | end 751 | 752 | local function tri_center(tri) 753 | return {x=(tri[1][1]+tri[2][1]+tri[3][1])/3,y=(tri[1][2]+tri[2][2]+tri[3][2])/3} 754 | end 755 | 756 | local function poly_area(pt) 757 | local s=0 758 | for i=1,#pt do 759 | local idx=i==#pt and 1 or i+1 760 | s=s+pt[i][1]*pt[idx][2]-pt[i][2]*pt[idx][1] 761 | end 762 | return math.abs(s/2) 763 | end 764 | 765 | local function poly_center(pt) 766 | local x,y=0,0 767 | for i=1,#pt do 768 | x,y=x+pt[i][1],y+pt[i][2] 769 | end 770 | return x/#pt,y/#pt 771 | end 772 | 773 | function polyc.reset_pts_idx(pts) 774 | local new={} 775 | for i=1,#pts do 776 | if pts[i].x then 777 | new[i]={pts[i].x,pts[i].y} 778 | else 779 | new[i]={x=pts[i][1],y=pts[i][2]} 780 | end 781 | end 782 | return new 783 | end 784 | 785 | function polyc.delaunay(p,sup) 786 | local sup=sup or {{-1000000,1000000},{0,-1000000},{1000000,1000000}} 787 | local final_tri=tin(p,sup) local s={} 788 | for i=1,#final_tri do 789 | local c=tri_center(final_tri[i]) 790 | s[i]={s=to_draw(final_tri[i],c.x,c.y),x=math_round(c.x,1),y=math_round(c.y,1)} 791 | end 792 | return s 793 | end 794 | 795 | function polyc.voronoi(p,x0,y0,w,h) 796 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 797 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local s={} 798 | local final_tri,p=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 799 | for i=1,#vor_cell do 800 | s[i]={s=to_draw(vor_cell[i],p[i][1],p[i][2]),x=math_round(p[i][1],1),y=math_round(p[i][2],1)} 801 | end 802 | return s 803 | end 804 | 805 | function polyc.tin_and_vor(p,x0,y0,w,h) 806 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 807 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local tri,vor={},{} 808 | local final_tri=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 809 | for i=1,#final_tri do 810 | local c=tri_center(final_tri[i]) 811 | tri[i]={s=to_draw(final_tri[i],c.x,c.y),x=math_round(c.x,1),y=math_round(c.y,1)} 812 | end 813 | for i=1,#vor_cell do 814 | vor[i]={s=to_draw(vor_cell[i],p[i][1],p[i][2]),x=math_round(p[i][1],1),y=math_round(p[i][2],1)} 815 | end 816 | return tri,vor 817 | end 818 | 819 | function polyc.vor_vortex(p,x0,y0,w,h,pct,n,area) 820 | local x0,y0,w,h=math.floor(x0),math.floor(y0),math.ceil(w),math.ceil(h) 821 | local sup={{-1000000,1000000},{0,-1000000},{1000000,1000000}} local s,poly={n={}},{} 822 | local final_tri,p=tin(p,sup) local vor_cell=voronoi_cell(final_tri,p,x0,y0,w,h) 823 | for i=1,#vor_cell do 824 | poly[i]={vor_cell[i]} local cnt=poly_area(vor_cell[i]) local cx,cy=poly_center(vor_cell[i]) 825 | s[i]={{s=to_draw(vor_cell[i],cx,cy),x=math_round(cx,1),y=math_round(cy,1)}} 826 | if not area then 827 | for i2=1,n do 828 | poly[i][i2+1]={} 829 | for i3=1,#vor_cell[i] do 830 | local idx=i3==#vor_cell[i] and 1 or i3+1 local x=(poly[i][i2][idx][1]-poly[i][i2][i3][1])*pct+poly[i][i2][i3][1] 831 | local y=(poly[i][i2][idx][2]-poly[i][i2][i3][2])*pct+poly[i][i2][i3][2] poly[i][i2+1][i3]={x,y} 832 | end 833 | s[i][i2+1]={s=to_draw(poly[i][i2+1],cx,cy),x=math_round(cx,1),y=math_round(cy,1)} 834 | end 835 | else 836 | while cnt>area do 837 | local num=#poly[i] poly[i][num+1]={} 838 | for i2=1,#vor_cell[i] do 839 | local idx=i2==#vor_cell[i] and 1 or i2+1 local x=(poly[i][num][idx][1]-poly[i][num][i2][1])*pct+poly[i][num][i2][1] 840 | local y=(poly[i][num][idx][2]-poly[i][num][i2][2])*pct+poly[i][num][i2][2] poly[i][num+1][i2]={x,y} 841 | end 842 | cnt=poly_area(poly[i][num+1]) 843 | s[i][num+1]={s=to_draw(poly[i][num+1],cx,cy),x=math_round(cx,1),y=math_round(cy,1)} 844 | end 845 | end 846 | s.n[i]=#s[i] 847 | end 848 | return s,poly 849 | end 850 | 851 | 852 | local polyb=require 'polyb' 853 | 854 | polyc.vor_shatter=polyb.vor_shatter 855 | 856 | polyc.vor_shatter2=polyb.vor_shatter2 857 | 858 | polyc.rect_vor_shatter=polyb.rect_vor_shatter 859 | 860 | polyc.circle_vor_shatter=polyb.circle_vor_shatter 861 | 862 | polyc.tin_shatter=polyb.tin_shatter 863 | 864 | 865 | function polyc.voronoi_move(frames,n,points_n,x0,y0,w,h) 866 | local p={} local each=math.ceil(frames/n) local s={n={{points_n,each*(n-1)}}} 867 | for i=1,n do 868 | p[i]=polyc.rand_coor(points_n,x0,y0,w,h) 869 | end 870 | for i=1,n-1 do 871 | for i1=1,each do 872 | local points={} 873 | for i2=1,points_n do 874 | points[i2]={(p[i+1][i2][1]-p[i][i2][1])*(i1-1)/(each-1)+p[i][i2][1],(p[i+1][i2][2]-p[i][i2][2])*(i1-1)/(each-1)+p[i][i2][2]} 875 | end 876 | s[#s+1]=polyc.voronoi(points,x0,y0,w,h) 877 | end 878 | end 879 | return s 880 | end 881 | 882 | 883 | _G.polyc=polyc 884 | return _G.polyc -------------------------------------------------------------------------------- /多边形库/布尔运算/polyb.lua: -------------------------------------------------------------------------------- 1 | 2 | local polyb={} 3 | 4 | local function math_round(n,digit) 5 | if digit and digit>=1 then 6 | digit=10^math.floor(digit) 7 | return math.floor(n*digit+0.5)/digit 8 | else return math.floor(n+0.5) 9 | end 10 | end 11 | 12 | 13 | local ffi=require "ffi" 14 | local C=ffi.load "polyc" 15 | 16 | ffi.cdef[[ 17 | typedef struct __CPoint { int32_t x; int32_t y; } CPoint; 18 | typedef struct __CRect { int32_t left, top, right, bottom; } CRect; 19 | typedef struct __CPath CPath; 20 | typedef struct __CPaths CPaths; 21 | typedef struct __CClipper CClipper; 22 | typedef struct __CClipperOffset CClipperOffset; 23 | typedef struct __CClipperTri CClipperTri; 24 | 25 | CPoint* CPointNew(int32_t x, int32_t y); 26 | void CPointDelete(CPoint* self); 27 | int CPointInPolygon(const CPoint* self, const CPath* path); 28 | 29 | CPath* CPathNew(); 30 | void CPathDelete(CPath* self); 31 | CPoint* CPathGet(CPath* self, int i); 32 | void CPathAdd(CPath* self, CPoint* pt); 33 | int CPathSize(CPath* self); 34 | double CPathArea(const CPath* self); 35 | bool CPathOrientation(const CPath* self); 36 | void CPathReverse(CPath* self); 37 | CPaths* CPathSimplify(CPath* self, int fillRule); 38 | 39 | CPaths* CPathsNew(); 40 | void CPathsDelete(CPaths* self); 41 | CPath* CPathsGet(CPaths* self, int i); 42 | void CPathsAdd(CPaths* self, CPath* path); 43 | int CPathsSize(CPaths* self); 44 | void CPathsReverse(CPaths* self); 45 | CPaths* CPathsSimplify(CPaths* self, int fillRule); 46 | CPaths* CPathsOffset(CPaths* self, double delta, int joinType, int endType, double miterLimit, double arcTolerance); 47 | CPaths* CPathsTriangulate(CPaths* self, int fillRule); 48 | 49 | CClipper* CClipperNew(); 50 | void CClipperDelete(CClipper* self); 51 | void CClipperAddPath(CClipper* self, CPath* path, int type, bool open); 52 | void CClipperAddPaths(CClipper* self, CPaths* paths, int type, bool open); 53 | CPaths* CClipperExecute(CClipper* self, int clipType, int fillRule); 54 | 55 | CClipperOffset* COffsetNew(double miterLimit, double arcTolerance); 56 | void COffsetDelete(CClipperOffset* self); 57 | void COffsetAddPath(CClipperOffset* self, CPath* path, int joinType, int endType); 58 | void COffsetAddPaths(CClipperOffset* self, CPaths* path, int joinType, int endType); 59 | CPaths* COffsetExecute(CClipperOffset* self, double delta); 60 | 61 | CClipperTri* CTriangulateNew(); 62 | void CTriangulateDelete(CClipperTri* self); 63 | void CTriangulateAddPath(CClipperTri* self, CPath* path); 64 | void CTriangulateAddPaths(CClipperTri* self, CPaths* paths); 65 | CPaths* CTriangulateExecute(CClipperTri* self, int fillRule); 66 | ]] 67 | 68 | _G.ClipType={None=0, Intersection=1, Union=2, Difference=3, Xor=4} 69 | _G.FillRule={EvenOdd=0, NonZero=1, Positive=2, Negative=3} 70 | _G.PathType={Subject=0, Clip=1} 71 | _G.JoinType={Square=0, Round=1, Mitter=2} 72 | _G.EndType={Polygon=0, OpenJoined=1, OpenButt=2, OpenSquare=3, OpenRound=4} 73 | 74 | local Point={} 75 | 76 | function Point.New(x, y) 77 | return ffi.gc(C.CPointNew(x, y), C.CPointDelete) 78 | end 79 | 80 | function Point:InPolygon(path) 81 | return C.CPointInPolygon(self, path) 82 | end 83 | 84 | local Path={} 85 | 86 | function Path.New() 87 | return ffi.gc(C.CPathNew(), C.CPathDelete) 88 | end 89 | 90 | function Path:Get(i) 91 | return C.CPathGet(self,i-1) 92 | end 93 | 94 | function Path:Add(pt) 95 | return C.CPathAdd(self,pt) 96 | end 97 | 98 | function Path:Size() 99 | return C.CPathSize(self) 100 | end 101 | 102 | function Path:Area() 103 | return C.CPathArea(self) 104 | end 105 | 106 | function Path:Orientation() 107 | return C.CPathOrientation(self) 108 | end 109 | 110 | function Path:Reverse() 111 | return C.CPathReverse(self) 112 | end 113 | 114 | function Path:Simplify(fillRule) 115 | local fillRule=fillRule or 0 116 | return C.CPathSimplify(self, fillRule) 117 | end 118 | 119 | local Paths={} 120 | 121 | function Paths.New() 122 | return ffi.gc(C.CPathsNew(),C.CPathsDelete) 123 | end 124 | 125 | function Paths:Get(i) 126 | return C.CPathsGet(self,i-1) 127 | end 128 | 129 | function Paths:Add(path) 130 | return C.CPathsAdd(self,path) 131 | end 132 | 133 | function Paths:Size() 134 | return C.CPathsSize(self) 135 | end 136 | 137 | function Paths:Reverse() 138 | return C.CPathsReverse(self) 139 | end 140 | 141 | function Paths:Simplify(fillRule) 142 | local fillRule=fillRule or 0 143 | return C.CPathsSimplify(self, fillRule) 144 | end 145 | 146 | function Paths:Offset(delta,joinType,endType,miterLimit,arcTolerance) 147 | local joinType=joinType or 1 148 | local endType=endType or 0 149 | local miterLimit=miterLimit or 2.0 150 | local arcTolerance=arcTolerance or 0.0 151 | return C.CPathsOffset(self,delta,joinType,endType,miterLimit,arcTolerance) 152 | end 153 | 154 | function Paths:Triangulate(fillRule) 155 | local fillRule=fillRule or 0 156 | return C.CPathsTriangulate(self,fillRule) 157 | end 158 | 159 | local Clipper={} 160 | 161 | function Clipper.New() 162 | return ffi.gc(C.CClipperNew(), C.CClipperDelete) 163 | end 164 | 165 | function Clipper:AddPath(path, pathType, open) 166 | local open=open or false 167 | C.CClipperAddPath(self, path, pathType, open) 168 | end 169 | 170 | function Clipper:AddPaths(paths, pathType, open) 171 | local open=open or false 172 | C.CClipperAddPaths(self, paths, pathType, open) 173 | end 174 | 175 | function Clipper:Execute(clipType, fillRule) 176 | local clipType=clipType or 1 177 | local fillRule=fillRule or 0 178 | return C.CClipperExecute(self, clipType, fillRule) 179 | end 180 | 181 | local ClipperOffset={} 182 | 183 | function ClipperOffset.New(miterLimit, arcTolerance) 184 | local miterLimit=miterLimit or 2.0 185 | local arcTolerance=arcTolerance or 0.0 186 | return ffi.gc(C.COffsetNew(miterLimit, arcTolerance), C.COffsetDelete) 187 | end 188 | 189 | function ClipperOffset:AddPath(path, joinType, endType) 190 | local joinType=joinType or 1 191 | local endType=endType or 0 192 | C.COffsetAddPath(self, path, joinType, endType) 193 | end 194 | 195 | function ClipperOffset:AddPaths(paths, joinType, endType) 196 | local joinType=joinType or 1 197 | local endType=endType or 0 198 | C.COffsetAddPaths(self, paths, joinType, endType) 199 | end 200 | 201 | function ClipperOffset:Execute(delta) 202 | return C.COffsetExecute(self, delta) 203 | end 204 | 205 | local ClipperTri={} 206 | 207 | function ClipperTri.New() 208 | return ffi.gc(C.CTriangulateNew(), C.CTriangulateDelete) 209 | end 210 | 211 | function ClipperTri:AddPath(path) 212 | C.CTriangulateAddPath(self, path) 213 | end 214 | 215 | function ClipperTri:AddPaths(paths) 216 | C.CTriangulateAddPath(self, paths) 217 | end 218 | 219 | function ClipperTri:Execute(fillRule) 220 | local fillRule=fillRule or 0 221 | return C.CTriangulateExecute(self, fillRule) 222 | end 223 | 224 | ffi.metatype("CPoint", {__index=Point}) 225 | ffi.metatype("CPath", {__index=Path}) 226 | ffi.metatype("CPaths", {__index=Paths}) 227 | ffi.metatype("CClipper", {__index=Clipper}) 228 | ffi.metatype("CClipperOffset", {__index=ClipperOffset}) 229 | ffi.metatype("CClipperTri", {__index=ClipperTri}) 230 | 231 | local Clib={ 232 | Point=Point.New, 233 | Path=Path.New, 234 | Paths=Paths.New, 235 | Clipper=Clipper.New, 236 | ClipperOffset=ClipperOffset.New, 237 | ClipperTri=ClipperTri.New 238 | } 239 | 240 | function polyb.simplify(ass_shape,accur,mode) 241 | local paths=Clib.Paths() local accur=accur or 2 local mode=mode or 1 242 | for m in ass_shape:gmatch('m[^m]+') do 243 | local s=Clib.Path() 244 | for x,y in m:gmatch('([-.%d]+) ([-.%d]+)') do 245 | s:Add(Clib.Point(x*10^accur,y*10^accur)) 246 | end 247 | paths:Add(s) 248 | end 249 | local obj=paths:Simplify(mode) local new={} 250 | for i=1,obj:Size() do 251 | local m=obj:Get(i) local s={} 252 | for i2=1,m:Size() do 253 | local pt=m:Get(i2) 254 | s[i2]=math_round(pt.x/10^accur,accur)..' '..math_round(pt.y/10^accur,accur)..' ' 255 | end 256 | new[i]='m '..table.concat(s,'l ') 257 | end 258 | return table.concat(new) 259 | end 260 | 261 | function polyb.get_poly_path(ass_shape,accur) 262 | local path=Clib.Path() local accur=accur or 2 263 | for x,y in ass_shape:gmatch('([-.%d]+) ([-.%d]+)') do 264 | path:Add(Clib.Point(x*10^accur,y*10^accur)) 265 | end 266 | return path 267 | end 268 | 269 | local function bezier_flat(pt,x1,y1,x2,y2,x3,y3,x4,y4) 270 | local function check_deg(px1,py1,px2,py2,px3,py3) 271 | local v1={px2-px1,py2-py1} local v2={px2-px3,py2-py3} local len1,len2=(v1[1]^2+v1[2]^2)^0.5,(v2[1]^2+v2[2]^2)^0.5 272 | if len1==0 or len2==0 then 273 | return true 274 | else return math.abs((v1[1]*v2[1]+v2[2]*v1[2])/(len1*len2))>0.9995 275 | end 276 | end 277 | local function flat(x1,y1,x2,y2,x3,y3,x4,y4) 278 | if check_deg(x1,y1,x2,y2,x3,y3) and check_deg(x2,y2,x3,y3,x4,y4) then 279 | pt:Add(Clib.Point(x4,y4)) 280 | else 281 | local f_x2,f_y2,f_x3,f_y3,x,y,s_x2,s_y2,s_x3,s_y3=Xshape.split_bezier_into_two(x1,y1,x2,y2,x3,y3,x4,y4) 282 | flat(x1,y1,f_x2,f_y2,f_x3,f_y3,x,y) 283 | flat(x,y,s_x2,s_y2,s_x3,s_y3,x4,y4) 284 | end 285 | end 286 | flat(x1,y1,x2,y2,x3,y3,x4,y4) 287 | end 288 | 289 | function polyb.get_paths(ass_shape,accur) 290 | local paths,accur=Clib.Paths(),accur or 2 local s 291 | local xmin,ymin,xmax,ymax=99999999999,99999999999,-99999999999,-99999999999 292 | for cmd,p in ass_shape:gmatch('([mlb])([-. %d]+)') do 293 | if cmd=='m' then 294 | if s then paths:Add(s) end s=Clib.Path() 295 | for x,y in p:gmatch('([-.%d]+) ([-.%d]+)') do 296 | s:Add(Clib.Point(x*10^accur,y*10^accur)) 297 | xmin,ymin,xmax,ymax=math.min(xmin,x),math.min(ymin,y),math.max(xmax,x),math.max(ymax,y) 298 | end 299 | elseif cmd=='l' then 300 | for x,y in p:gmatch('([-.%d]+) ([-.%d]+)') do 301 | s:Add(Clib.Point(x*10^accur,y*10^accur)) 302 | xmin,ymin,xmax,ymax=math.min(xmin,x),math.min(ymin,y),math.max(xmax,x),math.max(ymax,y) 303 | end 304 | else 305 | local pt=s:Get(s:Size()) local x1,y1,cnt=pt.x,pt.y,0 306 | for x2,y2,x3,y3,x4,y4 in p:gmatch('([-.%d]+) ([-.%d]+) ([-.%d]+) ([-.%d]+) ([-.%d]+) ([-.%d]+)') do 307 | xmin,ymin,xmax,ymax=math.min(xmin,x2,x3,x4),math.min(ymin,y2,y3,y4),math.max(xmax,x2,x3,x4),math.max(ymax,y2,y3,y4) 308 | x4,y4=x4*10^accur,y4*10^accur cnt=1 309 | bezier_flat(s,x1,y1,x2*10^accur,y2*10^accur,x3*10^accur,y3*10^accur,x4,y4) 310 | if cnt==1 then x1,y1=x4,y4 end 311 | end 312 | end 313 | end 314 | paths:Add(s) 315 | return paths,xmin,ymin,xmax,ymax,xmax-xmin,ymax-ymin,(xmin+xmax)/2,(ymin+ymax)/2 316 | end 317 | 318 | function polyb.get_poly_paths(ass_shape,accur) 319 | local paths=Clib.Paths() local accur=accur or 2 320 | for m in ass_shape:gmatch('m[^m]+') do 321 | local s=Clib.Path() 322 | for x,y in m:gmatch('([-.%d]+) ([-.%d]+)') do 323 | s:Add(Clib.Point(x*10^accur,y*10^accur)) 324 | end 325 | paths:Add(s) 326 | end 327 | return paths 328 | end 329 | 330 | function polyb.get_poly_paths_and_bounding(ass_shape,accur) 331 | local paths,x1,y1,x2,y2,accur=Clib.Paths(),99999999999,99999999999,-99999999999,-99999999999,accur or 2 332 | for m in ass_shape:gmatch('m[^m]+') do 333 | local s=Clib.Path() 334 | for x,y in m:gmatch('([-.%d]+) ([-.%d]+)') do 335 | s:Add(Clib.Point(x*10^accur,y*10^accur)) 336 | x1,y1=math.min(x1,x),math.min(y1,y) x2,y2=math.max(x2,x),math.max(y2,y) 337 | end 338 | paths:Add(s) 339 | end 340 | return paths,x1,y1,x2,y2,x2-x1,y2-y1,(x1+x2)/2,(y1+y2)/2 341 | end 342 | 343 | function polyb.paths_to_shape(paths,accur) 344 | local s={} local accur=accur or 2 345 | for i=1,paths:Size() do 346 | local m=paths:Get(i) local p={} 347 | for i2=1,m:Size() do 348 | local pt=m:Get(i2) 349 | p[i2]=math_round(pt.x/10^accur,accur)..' '..math_round(pt.y/10^accur,accur)..' ' 350 | end 351 | s[i]='m '..table.concat(p,'l ') 352 | end 353 | return table.concat(s) 354 | end 355 | 356 | function polyb.paths_to_shape_align(paths,accur) 357 | local s,accur,x1,y1,x2,y2={},accur or 2,99999999999,99999999999,-99999999999,-99999999999 358 | for i=1,paths:Size() do 359 | local m=paths:Get(i) local p={} 360 | for i2=1,m:Size() do 361 | local pt=m:Get(i2) local x,y=math_round(pt.x/10^accur,accur),math_round(pt.y/10^accur,accur)..' ' 362 | p[i2]={x,y} x1,y1=math.min(x1,x),math.min(y1,y) x2,y2=math.max(x2,x),math.max(y2,y) 363 | end 364 | s[i]=p 365 | end 366 | local cx,cy=(x1+x2)/2,(y1+y2)/2 367 | for i=1,#s do 368 | for i2=1,#s[i] do 369 | s[i][i2]=math_round(s[i][i2][1]-cx,2)..' '..math_round(s[i][i2][2]-cy,2)..' ' 370 | end 371 | s[i]='m '..table.concat(s[i],'l ') 372 | end 373 | return table.concat(s),math_round(cx,1),math_round(cy,1) 374 | end 375 | 376 | 377 | 378 | function polyb.shape_mesh_shape(ass_shape1,ass_shape2)--绘图1是否包含绘图2,绘图2是否包含绘图1 379 | local x1,y1=ass_shape1:match('m ([-.%d]+) ([-.%d]+) *$') local x2,y2=ass_shape2:match('m ([-.%d]+) ([-.%d]+) *$') 380 | if y2 then 381 | return Xshape.pt_in_shape(ass_shape1,x2,y2),false 382 | elseif y1 then 383 | return false,Xshape.pt_in_shape(ass_shape2,x1,y1) 384 | end 385 | local s1=polyb.simplify(ass_shape1) local s2=polyb.simplify(ass_shape2) local AND=polyb.intersection(ass_shape1,ass_shape2) 386 | return AND==s2,AND==s1 387 | end 388 | 389 | 390 | 391 | function polyb.intersection(ass_shape1,ass_shape2,accur,mode) 392 | local paths1=polyb.get_paths(ass_shape1,accur) local paths2=polyb.get_paths(ass_shape2,accur) local c=Clib.Clipper() 393 | local mode=mode or 1 c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 394 | local solution=c:Execute(1,mode) 395 | return polyb.paths_to_shape(solution,accur) 396 | end 397 | 398 | function polyb.union(ass_shape1,ass_shape2,accur,mode) 399 | local paths1=polyb.get_paths(ass_shape1,accur) local paths2=polyb.get_paths(ass_shape2,accur) local c=Clib.Clipper() 400 | local mode=mode or 1 c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 401 | local solution=c:Execute(2,mode) 402 | return polyb.paths_to_shape(solution,accur) 403 | end 404 | 405 | function polyb.difference(ass_shape1,ass_shape2,accur,mode) 406 | local paths1=polyb.get_paths(ass_shape1,accur) local paths2=polyb.get_paths(ass_shape2,accur) local c=Clib.Clipper() 407 | local mode=mode or 1 c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 408 | local solution=c:Execute(3,mode) 409 | return polyb.paths_to_shape(solution,accur) 410 | end 411 | 412 | function polyb.xor(ass_shape1,ass_shape2,accur,mode) 413 | local paths1=polyb.get_paths(ass_shape1,accur) local paths2=polyb.get_paths(ass_shape2,accur) local c=Clib.Clipper() 414 | local mode=mode or 1 c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 415 | local solution=c:Execute(4,mode) 416 | return polyb.paths_to_shape(solution,accur) 417 | end 418 | 419 | function polyb.intersections(ass_shapes,accur,mode) 420 | local mode=mode or 1 local solution 421 | for i=1,#ass_shapes-1 do 422 | local paths1=solution or polyb.get_paths(ass_shapes[i],accur) local paths2=polyb.get_paths(ass_shapes[i+1],accur) 423 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) solution=c:Execute(1,mode) 424 | end 425 | return polyb.paths_to_shape(solution,accur) 426 | end 427 | 428 | function polyb.unions(ass_shapes,accur,mode) 429 | local mode=mode or 1 local solution 430 | for i=1,#ass_shapes-1 do 431 | local paths1=solution or polyb.get_paths(ass_shapes[i],accur) local paths2=polyb.get_paths(ass_shapes[i+1],accur) 432 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) solution=c:Execute(2,mode) 433 | end 434 | return polyb.paths_to_shape(solution,accur) 435 | end 436 | 437 | function polyb.differences(ass_shapes,accur,mode) 438 | local mode=mode or 1 local solution 439 | for i=1,#ass_shapes-1 do 440 | local paths1=solution or polyb.get_paths(ass_shapes[i],accur) local paths2=polyb.get_paths(ass_shapes[i+1],accur) 441 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) solution=c:Execute(3,mode) 442 | end 443 | return polyb.paths_to_shape(solution,accur) 444 | end 445 | 446 | function polyb.xors(ass_shapes,accur,mode) 447 | local mode=mode or 1 local solution 448 | for i=1,#ass_shapes-1 do 449 | local paths1=solution or polyb.get_paths(ass_shapes[i],accur) local paths2=polyb.get_paths(ass_shapes[i+1],accur) 450 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) solution=c:Execute(4,mode) 451 | end 452 | return polyb.paths_to_shape(solution,accur) 453 | end 454 | 455 | function polyb.paths_intersection(paths1,paths2,mode) 456 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 457 | local mode=mode or 1 local solution=c:Execute(1,mode) 458 | return solution 459 | end 460 | 461 | function polyb.paths_union(paths1,paths2,mode) 462 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 463 | local mode=mode or 1 local solution=c:Execute(2,mode) 464 | return solution 465 | end 466 | 467 | function polyb.paths_difference(paths1,paths2,mode) 468 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 469 | local mode=mode or 1 local solution=c:Execute(3,mode) 470 | return solution 471 | end 472 | 473 | function polyb.paths_xor(paths1,paths2,mode) 474 | local c=Clib.Clipper() c:AddPaths(paths1,0,false) c:AddPaths(paths2,1,false) 475 | local mode=mode or 1 local solution=c:Execute(4,mode) 476 | return solution 477 | end 478 | 479 | function polyb.offset(ass_shape,d,jointype,endtype,accur,miter_limit,arc_tolerance) 480 | local accur=accur or 2 local paths1=polyb.get_paths(ass_shape,accur) local jointype=jointype or 1 local endtype=endtype or 4 481 | local miter_limit=miter_limit or 2 local arc_tolerance=arc_tolerance or 0 local paths2=paths1:Offset(d*10^accur,jointype,endtype,miter_limit,arc_tolerance) 482 | return polyb.paths_to_shape(paths2,accur) 483 | end 484 | 485 | function polyb.tri(ass_shape,accur,mode) 486 | local paths1=polyb.get_paths(ass_shape,accur) local mode=mode or 1 local paths2=paths1:Triangulate(mode) 487 | return polyb.paths_to_shape(paths2,accur) 488 | end 489 | 490 | function polyb.tbl_to_paths(tbl,accur) 491 | local paths=Clib.Paths() local accur=accur or 2 492 | for m=1,#tbl do 493 | local path=Clib.Path() 494 | for pt=1,#tbl[m] do 495 | path:Add(Clib.Point(tbl[m][pt][1]*10^accur,tbl[m][pt][2]*10^accur)) 496 | end 497 | paths:Add(path) 498 | end 499 | return paths 500 | end 501 | 502 | function polyb.paths_to_tbl(paths,accur) 503 | local tbl={} local accur=accur or 2 504 | for m=1,paths:Size() do 505 | local path=paths:Get(m) tbl[m]={} 506 | for i=1,path:Size() do 507 | local pt=path:Get(i) tbl[m][i]={math_round(pt.x/10^accur,accur),math_round(pt.y/10^accur,accur)} 508 | end 509 | end 510 | return tbl 511 | end 512 | 513 | function polyb.rect_shatter(ass_shape,w_copies,h_copies,accur) 514 | local paths1,left,top,_,_,w,h=polyb.get_paths(ass_shape,accur) local shatter={} 515 | for i=1,w_copies do 516 | for i2=1,h_copies do 517 | local x,y,width,height=left+(i-1)*w/w_copies,top+(i2-1)*h/h_copies,w/w_copies,h/h_copies 518 | local rect={{{x,y},{x+width,y},{x+width,y+height},{x,y+height}}} 519 | local paths=polyb.paths_intersection(paths1,polyb.tbl_to_paths(rect,accur)) 520 | local AND,c,m=polyb.paths_to_shape_align(paths,accur) 521 | if AND~='' then 522 | shatter[#shatter+1]={s=AND,x=c,y=m} 523 | end 524 | end 525 | end 526 | return shatter 527 | end 528 | 529 | function polyb.rects_shatter(ass_shape,n,w_copies,h_copies,accur) 530 | local rect,rects,shatter={},{},{} local paths1,left,top,_,_,w,h=polyb.get_paths(ass_shape,accur) 531 | for i=1,w_copies do 532 | for i2=1,h_copies do 533 | local x,y,width,height=left+(i-1)*w/w_copies,top+(i2-1)*h/h_copies,w/w_copies,h/h_copies 534 | rect[#rect+1]={{x,y},{x+width,y},{x+width,y+height},{x,y+height}} 535 | end 536 | end 537 | for i=1,n do 538 | rects[i]={} 539 | end 540 | for i=1,#rect do 541 | local idx=math.random(n) 542 | rects[idx][#rects[idx]+1]=rect[i] 543 | end 544 | for i=1,n do 545 | local paths=polyb.paths_intersection(paths1,polyb.tbl_to_paths(rects[i],accur)) 546 | local AND,c,m=polyb.paths_to_shape_align(paths,accur) 547 | if AND~='' then 548 | shatter[#shatter+1]={s=AND,x=c,y=m} 549 | end 550 | end 551 | return shatter 552 | end 553 | 554 | function polyb.cycle_tri(ass_shape,copies,accur) 555 | local paths1,_,_,_,_,w,h,c,m=polyb.get_paths(ass_shape,accur) local deg,r,shatter=math.rad(360/copies),w^2+h^2,{} 556 | for i=1,copies do 557 | local tri={{{c,m},{c+math.cos(deg*(i-1))*r,m+math.sin(deg*(i-1))*r},{c+math.cos(deg*i)*r,m+math.sin(deg*i)*r}}} 558 | local paths=polyb.paths_intersection(paths1,polyb.tbl_to_paths(tri,accur)) 559 | local AND,x,y=polyb.paths_to_shape_align(paths,accur) 560 | if AND~='' then 561 | shatter[#shatter+1]={s=AND,x=x,y=y} 562 | end 563 | end 564 | return shatter 565 | end 566 | 567 | function polyb.cycle_tri_rand(ass_shape,copies,accur) 568 | local paths1,_,_,_,_,w,h,c,m=polyb.get_paths(ass_shape,accur) local cx,cy=c+math.random(-w,w)*3/8,m+math.random(-h,h)*3/8 569 | local deg,r,shatter=math.rad(360/copies),w^2+h^2,{} 570 | for i=1,copies do 571 | local tri={{{cx,cy},{cx+math.cos(deg*(i-1))*r,cy+math.sin(deg*(i-1))*r},{cx+math.cos(deg*i)*r,cy+math.sin(deg*i)*r}}} 572 | local paths=polyb.paths_intersection(paths1,polyb.tbl_to_paths(tri,accur)) 573 | local AND,x,y=polyb.paths_to_shape_align(paths,accur) 574 | if AND~='' then 575 | shatter[#shatter+1]={s=AND,x=x,y=y} 576 | end 577 | end 578 | return shatter 579 | end 580 | 581 | function polyb.cut(ass_shape,mode,accur) 582 | local paths1,x1,y1,x2,y2,w,h=polyb.get_paths(ass_shape,accur) local c,m,x,y 583 | local mode=mode or 1 local shatter={} if mode~=1 and mode~=2 then mode=math.random(1,2) end 584 | if mode==1 then 585 | local d=math.random(h) local s1={{{x1,y1+d},{x1,y1},{x2,y1},{x2,y2-d}}} local s2={{{x1,y1+d},{x2,y2-d},{x2,y2},{x1,y2}}} 586 | local AND1=polyb.paths_intersection(paths1,polyb.tbl_to_paths(s1,accur)) 587 | local AND2=polyb.paths_intersection(paths1,polyb.tbl_to_paths(s2,accur)) 588 | AND1,c,m=polyb.paths_to_shape_align(AND1,accur) AND2,x,y=polyb.paths_to_shape_align(AND2,accur) 589 | local v1={d0 then 788 | orientation[#orientation+1]=1 789 | elseif s==0 then 790 | orientation[#orientation+1]=0 791 | else orientation[#orientation+1]=-1 792 | end 793 | area=area+s/2 794 | end 795 | return math.abs(area),orientation[1],orientation 796 | end 797 | 798 | function polyb.pixelate(ass_shape,n1,n2,ala,clr1,clr2) 799 | local paths,left,top,_,_,width,height,center,middle=polyb.get_paths(ass_shape) 800 | local n1,n2=n1 or 3,n2 or 10 local px={n={}} 801 | local clr1,clr2=clr1 or '&HFFFFFF&',clr2 or '&H000000&' 802 | for i=n1,n2 do 803 | local w,h=width/i,height/i local x0,y0=left+w/2,top+h/2 local main={} 804 | local x1,y1,x2,y2=math.round(-w/2,1),math.round(-h/2,1),math.round(w/2,1),math.round(-h/2,1) 805 | local x3,y3,x4,y4=math.round(w/2,1),math.round(h/2,1),math.round(-w/2,1),math.round(h/2,1) 806 | px[i-n1+1]={} local rect='m '..x1..' '..y1..' l '..x2..' '..y2..' l '..x3..' '..y3..' l '..x4..' '..y4..' ' 807 | for xi=1,i do 808 | for yi=1,i do 809 | local cx,cy=x0+(xi-1)*w,y0+(yi-1)*h 810 | local u1,v1,u2,v2,u3,v3,u4,v4=x1+cx,y1+cy,x2+cx,y2+cy,x3+cx,y3+cy,x4+cx,y4+cy 811 | local tbl={{{u1,v1},{u2,v2},{u3,v3},{u4,v4}}} 812 | local s=polyb.paths_intersection(paths,polyb.tbl_to_paths(tbl)) 813 | if s:Size()>0 then 814 | local area=poly_area(s) local pct=area/(w*h) 815 | if ala then 816 | local a=255*(1-pct) a=a<0 and 0 or a>255 and 255 or a 817 | if a==0 then 818 | u1,v1,u2,v2=math.round(u1-center,1),math.round(v1-middle,1),math.round(u2-center,1),math.round(v2-middle,1) 819 | u3,v3,u4,v4=math.round(u3-center,1),math.round(v3-middle,1),math.round(u4-center,1),math.round(v4-middle,1) 820 | main[#main+1]='m '..u1..' '..v1..' l '..u2..' '..v2..' l '..u3..' '..v3..' l '..u4..' '..v4..' ' 821 | else 822 | px[i-n1+1][#px[i-n1+1]+1]={x=math.round(cx,1),y=math.round(cy,1),s=rect,a=("&H%02X&"):format(a)} 823 | end 824 | else 825 | local b,g,r=clr1:match('&H(..)(..)(..)&') local b1,g1,r1=clr2:match('&H(..)(..)(..)&') 826 | b,g,r=tonumber(b,16),tonumber(g,16),tonumber(r,16) b1,g1,r1=tonumber(b1,16),tonumber(g1,16),tonumber(r1,16) 827 | local b2,g2,r2=b*pct+b1*(1-pct),g*pct+g1*(1-pct),r*pct+r1*(1-pct) 828 | b2,g2,r2=b2>255 and 255 or b2<0 and 0 or b2,g2>255 and 255 or g2<0 and 0 or g2,r2>255 and 255 or r2<0 and 0 or r2 829 | local c=("&H%02X%02X%02X&"):format(b2,g2,r2) 830 | if c==clr1 then 831 | u1,v1,u2,v2=math.round(u1-center,1),math.round(v1-middle,1),math.round(u2-center,1),math.round(v2-middle,1) 832 | u3,v3,u4,v4=math.round(u3-center,1),math.round(v3-middle,1),math.round(u4-center,1),math.round(v4-middle,1) 833 | main[#main+1]='m '..u1..' '..v1..' l '..u2..' '..v2..' l '..u3..' '..v3..' l '..u4..' '..v4..' ' 834 | else 835 | px[i-n1+1][#px[i-n1+1]+1]={x=math.round(cx,1),y=math.round(cy,1),s=rect,c=c} 836 | end 837 | end 838 | end 839 | end 840 | end 841 | if #main>0 then 842 | px[i-n1+1][#px[i-n1+1]+1]={x=math.round(center,1),y=math.round(middle,1),s=table.concat(main),c=clr1,a='&H00&'} 843 | end 844 | px.n[i-n1+1]=#px[i-n1+1] 845 | end 846 | return px 847 | end 848 | 849 | 850 | 851 | 852 | _G.polyb=polyb 853 | 854 | return _G.polyb 855 | 856 | 857 | -------------------------------------------------------------------------------- /多边形库/布尔运算/polyc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/多边形库/布尔运算/polyc.dll -------------------------------------------------------------------------------- /转载请注明作者和出处!.txt: -------------------------------------------------------------------------------- 1 | 我的b站账号:https://space.bilibili.com/346816900 2 | -------------------------------------------------------------------------------- /音频频谱/Thank you, my twilight.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/音频频谱/Thank you, my twilight.mp3 -------------------------------------------------------------------------------- /音频频谱/b站视频BV1C44y1B7CJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /音频频谱/ヒーロー supercell.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/音频频谱/ヒーロー supercell.mp3 -------------------------------------------------------------------------------- /音频频谱/二胡.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/音频频谱/二胡.wav -------------------------------------------------------------------------------- /音频频谱/任意路径频谱.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/音频频谱/任意路径频谱.zip -------------------------------------------------------------------------------- /音频频谱/圆柱频谱.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WitchCraftWorks66/StupidAss/be2f9aa0884f05a7729b29f7395ad970e6c5a46d/音频频谱/圆柱频谱.7z --------------------------------------------------------------------------------