Skip to content

Commit

Permalink
new file: .vscode/settings.json
Browse files Browse the repository at this point in the history
	modified:   C Centralize Drawing.lua
	modified:   C Effect Dissolve.lua
	modified:   C Gradient.lua
	modified:   C Translation.lua
  • Loading branch information
zhang-changwei committed Feb 16, 2021
1 parent a4a9746 commit 092e896
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Lua.diagnostics.globals": [
"script_version",
"script_author",
"script_description",
"script_name",
"aegisub",
"karaskel",
"include",
"lfs"
],
"Lua.diagnostics.disable": [
"lowercase-global"
]
}
8 changes: 4 additions & 4 deletions C Centralize Drawing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function Centralization(subtitle, selected, active)
for si,li in ipairs(selected) do
line=subtitle[li]

if (line.text:match("\\pos")==nil) then line.text=line.text:gsub("^{","{\\pos(0,0)")
if (line.text:match("\\pos")==nil) then line.text=line.text:gsub("^{","{\\pos(0,0)") end
if (line.text:match("\\an")==nil) then line.text=line.text:gsub("^{","{\\an7") end

line:text=line.text:gsub("\\fsc[%d%.%-]+","")
line:text=line.text:gsub("\\fscx[%d%.%-]+","")
line:text=line.text:gsub("\\fscy[%d%.%-]+","")
line.text=line.text:gsub("\\fsc[%d%.%-]+","")
line.text=line.text:gsub("\\fscx[%d%.%-]+","")
line.text=line.text:gsub("\\fscy[%d%.%-]+","")
line.text=line.text:gsub("\\an%d","\\an7")
line.text=line.text:gsub("\\pos%([^%)]+%)","\\pos(0,0)\\fscx100\fscy100")

Expand Down
10 changes: 5 additions & 5 deletions C Effect Dissolve.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Select one line and run the script

--Script properties
script_name="C Effect Dissolove"
script_description="Dissolve"
script_description="Effect Dissolve v1.0.1"
script_author="chaaaaang"
script_version="1.0"
script_version="1.0.1"

include("karaskel.lua")

Expand Down Expand Up @@ -62,10 +62,10 @@ function main(subtitle, selected)
local fscyinline = tonumber(ltext:match("\\fscy([%d%.]+)"))
local an = line.styleref.align
if (ltext:match("\\an%d")~=nil) then an = tonumber(ltext:match("\\an(%d)")) end
local left,top,right,bottom,width,height,center,middle=0
local left,top,right,bottom,width,height,center,middle=0,0,0,0,0,0,0,0

--ratio
local ratiox,ratioy = 1
local ratiox,ratioy = 1,1
if (ltext:match("\\fs")~=nil) then
ratiox = tonumber(ltext:match("\\fs([%d%.]+)")) / line.styleref.fontsize
ratioy = tonumber(ltext:match("\\fs([%d%.]+)")) / line.styleref.fontsize
Expand All @@ -74,7 +74,7 @@ function main(subtitle, selected)
ratiox = tonumber(ltext:match("\\fscx([%d%.]+)")) / line.styleref.scale_x
end
if (ltext:match("\\fscy")~=nil) then
ratiox = tonumber(ltext:match("\\fscy([%d%.]+)")) / line.styleref.scale_x
ratioy = tonumber(ltext:match("\\fscy([%d%.]+)")) / line.styleref.scale_y
end
width = line.width * ratiox
height = line.height * ratioy
Expand Down
4 changes: 2 additions & 2 deletions C Gradient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function main(subtitle, selected)
else
--first get l1 & ln
--line count = N, time count = T
local i,start_f,end_f,l1,ln = 0
local i,start_f,end_f,l1,ln = 0,0,0,0,0

for sa,la in ipairs(selected) do
local line = subtitle[la]
Expand Down Expand Up @@ -604,7 +604,7 @@ function interpolate_c(bias,head,tail)
g2 = tonumber(g2,16)
r1 = tonumber(r1,16)
r2 = tonumber(r2,16)
local b,g,r = 0
local b,g,r = 0,0,0
if (b1==b2) then b = b1 else b = math.floor((b2-b1)*bias+0.5)+b1 end
if (g1==g2) then g = g1 else g = math.floor((g2-g1)*bias+0.5)+g1 end
if (r1==r2) then r = r1 else r = math.floor((r2-r1)*bias+0.5)+r1 end
Expand Down
20 changes: 10 additions & 10 deletions C Translation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function main(subtitle, selected, active)
xres, yres, ar, artype = aegisub.video_size()

--count the size N,T
local i,start_f,end_f = 0
local i,start_f,end_f = 0,0,0

for sa,la in ipairs(selected) do
local line = subtitle[la]
Expand All @@ -186,11 +186,11 @@ function main(subtitle, selected, active)
pressed, result = aegisub.dialog.display(dialog_config,buttons)
if (pressed=="Quit") then aegisub.cancel() end
--all false
if (result["posx"]==false and result["posy"]==false and result["fscx"]==false and result["fscy"]==false and result["clip_x"]==false and result["clip_y"]==false and result["frz"]==false and result["other_button"]==false) then
if (result["posx"]==false and result["posy"]==false and result["fscx"]==false and result["fscy"]==false and result["clip_x"]==false and result["clip_y"]==false and result["frz"]==false and result["other_button"]==false) then
aegisub.cancel()
else
--loop begins
local i = 0
local i = 0
for si,li in ipairs(selected) do
i = i + 1
local line=subtitle[li]
Expand All @@ -204,7 +204,7 @@ function main(subtitle, selected, active)
linetext = line.text
end
linetext = linetext:gsub("}{","")

--posx posy
if (result["posx"]==true or result["posy"]==true) then
--confirm the \pos is in the tag
Expand Down Expand Up @@ -271,12 +271,12 @@ function main(subtitle, selected, active)
--clip
if (result["clip_x"]==true or result["clip_y"]==true) then
linetext = linetext:gsub("(\\[i]?clip)([^%)]+)%)",
function(c,d)
function(c,d)
--odd or even xyxy
local o_e=0
local trs_clip = c
local trs_clip = c
for head,num in d:gmatch("([^%d%.%-]+)([%d%.%-]+)") do
if (o_e == 0 and result["clip_x"]==true) then
if (o_e == 0 and result["clip_x"]==true) then
trs_clip = string.format("%s%s%.2f",trs_clip,head,num+interpolate(result["clip_x_start"],result["clip_x_end"],result["clip_x_accel"],N,T,i,t,result["set"],result["clip_x_deviation"],result["clip_x_transverse"],pressed))
elseif (o_e == 1 and result["clip_y"]==true) then
trs_clip = string.format("%s%s%.2f",trs_clip,head,num+interpolate(result["clip_y_start"],result["clip_y_end"],result["clip_y_accel"],N,T,i,t,result["set"],result["clip_y_deviation"],result["clip_y_transverse"],pressed))
Expand Down Expand Up @@ -341,8 +341,8 @@ function main(subtitle, selected, active)
end
--loop ends
end
aegisub.set_undo_point(script_name)
return selected
aegisub.set_undo_point(script_name)
return selected
end

function interpolate(head,tail,accel,N,T,i,t,judge,deviation,transverse,button)
Expand All @@ -366,7 +366,7 @@ function interpolate(head,tail,accel,N,T,i,t,judge,deviation,transverse,button)
else
return 0
end

end

function translation(linetext,tagtype,deviation,index,match,matchtail)
Expand Down

0 comments on commit 092e896

Please sign in to comment.