@モザイクT
--track0:サイズ,1,1000,50
--dialog:タイル風/chk,local te=0;タイル補正/chk,local ho=1;
--check0:滑らか,0
	local t=obj.getvalue("scenechange")
	if obj.check0 then t=t*t*(3-2*t) end
	local a=4*t-1.5
	if a<0 then a=0 elseif a>1 then a=1 end
	local s=(obj.track0-1)*(1-math.abs(2*t-1))+1
	if te==1 and ho==1 and s<10 then
		obj.copybuffer("cache:bf","obj")
	end
	obj.copybuffer("tmp","frm")
	obj.copybuffer("cache:af","tmp")
	
	obj.effect("モザイク","サイズ",s,"タイル風",te)
	obj.draw()
	obj.copybuffer("obj","cache:af")
	obj.effect("モザイク","サイズ",s,"タイル風",te)
	obj.draw(0,0,0,1,a)
	
	if te==1 and ho==1 and s<10 then
		local w,h = obj.getpixel()
		obj.setoption("drawtarget","tempbuffer",w,h)
		obj.copybuffer("obj","cache:bf")
		obj.effect("モザイク","サイズ",s)
		obj.draw()
		obj.copybuffer("obj","cache:af")
		obj.effect("モザイク","サイズ",s)
		obj.draw(0,0,0,1,a)
		obj.load("tempbuffer")
		obj.setoption("drawtarget","framebuffer")
		obj.draw(0,0,0,1,(10-s)/9)
	end

@矩形T
--track0:幅,5,1000,100
--track1:角度,-3600,3600,0
--dialog:先端幅[0〜50]％,local S2=35;高さ,local D0=50;

local ROT=function(x,y,cos,sin)
	return x*cos-y*sin,x*sin+y*cos
end

	local w=obj.w
	local h=obj.h

	if S2>50 then S2=50 elseif S2<0 then S2=0 end
	local t=1-obj.getvalue("scenechange")

	local S0=obj.track0
				S2=S0*S2*0.01
	local S1=S0-S2
	local S1h=S1*0.5
	local S2h=S2*0.5
	local D0h=D0*0.5

	local deg=obj.track1
	local rad=deg*math.pi/180

	obj.copybuffer("cache:bf","obj")

	obj.setoption("drawtarget","tempbuffer",S0+2,D0+2)
	obj.load("figure","四角形",0xffffff,math.max(S0,D0))

	obj.drawpoly(-S1h,-D0h ,0, S1h,-D0h ,0, S2h,D0h,0, -S2h,D0h,0)
	obj.drawpoly(-S1h-1,-D0h-1,0, S1h+1,-D0h-1,0, S1h,-D0h,0, -S1h,-D0h,0)
	obj.copybuffer("obj","tmp")
	obj.setoption("blend","alpha_sub")

	obj.copybuffer("tmp","cache:bf")

	local cos=math.cos(rad)
	local sin=math.sin(rad)
	local abcos=math.abs(cos)
	local absin=math.abs(sin)
	local ww=w*abcos+h*absin
	local hh=h*abcos+w*absin

	local w2=ww*0.5
	local h2=hh*0.5

	local n1=-math.floor(-w2/S0)

	y=t*(h2+D0h)
	for i=-n1,n1 do
		local x1,y1=ROT(i*S0,-y,cos,sin)
		obj.draw(x1,y1,0,1,1,0,0,deg)
	end
	local deg2=180+deg
	for i=1,n1 do
		local dx=(i-0.5)*S0
		local x1,y1=ROT(dx,y,cos,sin)
		obj.draw(x1,y1,0,1,1,0,0,deg2)
		x1,y1=ROT(-dx,y,cos,sin)
		obj.draw(x1,y1,0,1,1,0,0,deg2)
	end

	obj.load("figure","四角形",0xffffff,math.max(w,h))
	obj.setoption("blend","alpha_sub")
	y=y+D0h
	local x0,y0=ROT(-w2,-h2,cos,sin)
	local x1,y1=ROT(w2,-h2,cos,sin)
	local x2,y2=ROT(w2,-y,cos,sin)
	local x3,y3=ROT(-w2,-y,cos,sin)
	obj.drawpoly(x0,y0,0, x1,y1,0, x2,y2,0, x3,y3,0)
	x0,y0=ROT(-w2,y,cos,sin)
	x1,y1=ROT(w2,y,cos,sin)
	x2,y2=ROT(w2,h2,cos,sin)
	x3,y3=ROT(-w2,h2,cos,sin)
	obj.drawpoly(x0,y0,0, x1,y1,0, x2,y2,0, x3,y3,0)

	obj.copybuffer("obj","tmp")
	obj.setoption("drawtarget","framebuffer")
	obj.draw()


@ブラースライドT
--track0:ブラー量,0,5000,50
--track1:流れ方向,0,1,0,1
--dialog:分割数,local SC=20;

local calP=function(s,N)
	local t

	if N>2 then
		local ss=s
		if s>N*0.5 then ss=N-s end
		if ss>0.5 then
			t=0.25+(math.sqrt((8*ss-4)*(N-2)+1)-1)/(8*(N-2))
		else
			t=ss*0.5
		end
		if s>N*0.5 then t=1-t end
	else
		t=s/N
	end

	return t
end

	local range=obj.track0*0.5
	local stype=obj.track1

	local TF=obj.totalframe
	local N=(TF+2)*0.5
	local s=math.floor(obj.getvalue("scenechange")*(TF+2)-0.5)

	local w,h = obj.getpixel()
	local w2,h2=w/2,h/2

	obj.copybuffer("cache:ch","obj")
	obj.setoption("drawtarget","tempbuffer",w,h)

	if stype==0 then
	
		obj.drawpoly(-w2,-h2,0, 0,-h2,0, 0,h2,0, -w2,h2,0)
		obj.copybuffer("obj","frm")
		obj.drawpoly(0,-h2,0, w2,-h2,0, w2,h2,0, 0,h2,0)
		obj.copybuffer("obj","tmp")
		obj.effect("方向ブラー","範囲",range,"角度",-90,"サイズ固定",1)
		obj.setoption("antialias",0)
		local dx=1/SC
		local dw=w/SC
		for i=0,SC-1 do
			local x0=s*0.5+i*dx
			local x1=x0+dx
			local u0=w*calP(x0,N)
			local u1=w*calP(x1,N)
			x0=-w2+i*dw
			x1=x0+dw
			obj.drawpoly(x0,-h2,0, x1,-h2,0, x1,h2,0, x0,h2,0, u0,0, u1,0, u1,h, u0,h)
		end
		if s==0 then
			obj.copybuffer("obj","cache:ch")
			obj.effect("斜めクリッピング","角度",-90,"ぼかし",w/3,"中心X",-w/6)
			obj.draw()
		end
		if s==TF then
			obj.load("framebuffer")
			obj.effect("斜めクリッピング","角度",90,"ぼかし",w/3,"中心X",w/6)
			obj.draw()
		end
	else
	
		obj.drawpoly(-w2,-h2,0, w2,-h2,0, w2,0,0, -w2,0,0)
		obj.copybuffer("obj","frm")
		obj.drawpoly(-w2,0,0, w2,0,0, w2,h2,0, -w2,h2,0)
		obj.copybuffer("obj","tmp")
		obj.effect("方向ブラー","範囲",range,"角度",0,"サイズ固定",1)
		obj.setoption("antialias",0)
		local dy=1/SC
		local dh=h/SC
		for i=0,SC-1 do
			local y0=s*0.5+i*dy
			local y1=y0+dy
			local v0=h*calP(y0,N)
			local v1=h*calP(y1,N)
			y0=-h2+i*dh
			y1=y0+dh
			obj.drawpoly(-w2,y0,0, w2,y0,0, w2,y1,0, -w2,y1,0, 0,v0, w,v0, w,v1, 0,v1)
		end
		if s==0 then
			obj.copybuffer("obj","cache:ch")
			obj.effect("斜めクリッピング","角度",0,"ぼかし",h/3,"中心Y",-h/6)
			obj.draw()
		end
		if s==TF then
			obj.load("framebuffer")
			obj.effect("斜めクリッピング","角度",180,"ぼかし",h/3,"中心Y",h/6)
			obj.draw()
		end
	end
		
	obj.copybuffer("obj","tmp")
	obj.setoption("drawtarget","framebuffer")
	obj.draw()

@分割スライドT
--track0:単独量,0,100,40
--track1:モード,0,3,1,1
--dialog:分割数,local N=5;
--check0:縦,0

	obj.copybuffer("tmp","obj")
	obj.setoption("drawtarget","tempbuffer")
	obj.setoption("blend","alpha_sub")


	local T=obj.getvalue("scenechange")
	local L=obj.track0*0.01
	N=math.floor(N)
	local MD=2*math.floor(obj.track1)
	local dL=(N*L-1)/(N-1)
	if dL<=0 then dL=0 end

	local ow=obj.w
	local oh=obj.h
	local ow2=0.5*ow
	local oh2=0.5*oh

	if obj.check0 then
	
		for k=1,N do
			local	kk
			if MD%4<=1 then 
				kk=k
			else
				kk=N-k+1
			end

			local x0=(k-1)*ow/N-ow2
			local x1=k*ow/N-ow2
			if (kk-1)*(L-dL)+L<=T then	--全表示
				obj.drawpoly(x0,-oh2,0, x1,-oh2,0, x1,oh,0, x0,oh,0)
			else
				 dh=(T-(kk-1)*(L-dL))*oh/L
				 if dh<=0 then dh=0 end
				 if MD>=4 and (MD+k)%2==0 then 
					 obj.drawpoly(x0,oh2-dh,0, x1,oh2-dh,0, x1,oh2,0, x0,oh2,0)
				 else
					 obj.drawpoly(x0,-oh2,0, x1,-oh2,0, x1,dh-oh2,0, x0,dh-oh2,0)
				 end
			end
		end --k
	
	else
	
		for k=1,N do
			local	kk
			if MD%4<=1 then 
				kk=k
			else
				kk=N-k+1
			end

			local y0=(k-1)*oh/N-oh2
			local y1=k*oh/N-oh2
			if (kk-1)*(L-dL)+L<=T then	--全表示
				obj.drawpoly(-ow2,y0,0, ow2,y0,0, ow2,y1,0, -ow2,y1,0)
			else
				 dw=(T-(kk-1)*(L-dL))*ow/L
				 if dw<=0 then dw=0 end
				 if MD>=4 and (MD+k)%2==0 then 
					 obj.drawpoly(ow2-dw,y0,0, ow2,y0,0, ow2,y1,0, ow2-dw,y1,0)
				 else
					 obj.drawpoly(-ow2,y0,0, dw-ow2,y0,0, dw-ow2,y1,0, -ow2,y1,0)
				 end
			end
		end --k
	end
	obj.copybuffer("obj","tmp")
	obj.setoption("drawtarget","framebuffer")
	obj.draw()

@ルミナンスT
--track0:ぼかし％,0,100,10
--check0:透過反転,1

	local blur=4096*obj.track0*0.01
	local T=obj.getvalue("scenechange")
	local L=(4096+2*blur)*T-blur

	obj.copybuffer("tmp","obj")
	obj.setoption("drawtarget","tempbuffer")
	obj.setoption("blend","alpha_sub")

	obj.effect("単色化")
	if obj.check0 then
		obj.effect("反転","輝度反転",1) 
	end
	obj.effect("ルミナンスキー","基準輝度",L,"ぼかし",blur,"type",1)
	obj.draw()

	obj.copybuffer("obj","tmp")
	obj.setoption("drawtarget","framebuffer")
	obj.draw()

@ホールT
--track0:サイズ,10,2000,100
--track1:開時間％,0.1,100,10
--dialog:ランダム性％,local rdp=100;乱数シード,local seed=5;

	local T=obj.getvalue("scenechange")
	local sz=obj.track0
	local opt=obj.track1*0.01
	local clt=1-opt
	local w=obj.w
	local h=obj.h
	local w2=w*0.5
	local h2=h*0.5
	local nx=math.ceil(w/sz)
	local ny=math.ceil(h/sz)
	local szh=sz
	local szb=2*sz
	rdp=rdp*0.01
	if rdp<0 then rdp=1 elseif rdp>1 then rdp=1 end
	local x={}
	local y={}

	for i=0,nx do
		x[i]={}
		y[i]={}
		local ix=i*sz
		for j=0,ny do
			x[i][j]=  ix+obj.rand(-sz,sz,i,j+seed+1000)*rdp
			y[i][j]=j*sz+obj.rand(-sz,sz,i,j+seed+2000)*rdp
		end
	end

	for i=0,nx do
		y[i][0]=0
		y[i][ny]=h
	end

	for j=0,ny do
		x[0][j]=0
		x[nx][j]=w
	end

	local stt={}
	local sttmax=0
	local sttmin=1000
	for i=0,nx-1 do
		stt[i]={}
		for j=0,ny-1 do
			stt[i][j]=obj.rand(0,1000,i,j+seed+3000)
			if sttmax<stt[i][j] then sttmax=stt[i][j] end
			if sttmin>stt[i][j] then sttmin=stt[i][j] end
		end
	end

	clt=clt/(sttmax-sttmin)
	for i=0,nx-1 do
		for j=0,ny-1 do
			stt[i][j]=clt*(stt[i][j]-sttmin)
		end
	end

	obj.copybuffer("tmp","obj")
	obj.setoption("drawtarget","tempbuffer")
	obj.setoption("blend","alpha_sub")
	
	obj.load("figure","円",0xffffff,szb)
	for i=0,nx-1 do
		for j=0,ny-1 do
			local dt=(T-stt[i][j])/opt
			if dt>1 then dt=1 end
			if dt>0 then 
				local cx=(x[i][j]+x[i+1][j]+x[i+1][j+1]+x[i][j+1])*0.25
				local cy=(y[i][j]+y[i+1][j]+y[i+1][j+1]+y[i][j+1])*0.25	
				local d1=(x[i][j]-cx)*(x[i][j]-cx)+(y[i][j]-cy)*(y[i][j]-cy)
				local d2=(x[i+1][j]-cx)*(x[i+1][j]-cx)+(y[i+1][j]-cy)*(y[i+1][j]-cy)
				local d3=(x[i+1][j+1]-cx)*(x[i+1][j+1]-cx)+(y[i+1][j+1]-cy)*(y[i+1][j+1]-cy)
				local d4=(x[i][j+1]-cx)*(x[i][j+1]-cx)+(y[i][j+1]-cy)*(y[i][j+1]-cy)
				d1=2*math.sqrt(math.max(d1,d2,d3,d4))
				obj.draw(cx-w2,cy-h2,0,d1/(szb)*dt)
			end
		end
	end
	
	obj.copybuffer("obj","tmp")
	obj.setoption("drawtarget","framebuffer")
	obj.draw()