Skip to content

Commit

Permalink
modified: C Utilities.lua
Browse files Browse the repository at this point in the history
	modified:   README.md
	modified:   with Yutils/C Effect.lua
  • Loading branch information
zhang-changwei committed Aug 11, 2021
1 parent a74dfcc commit d520ecf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
34 changes: 21 additions & 13 deletions C Utilities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ goto my repository https://github.com/zhang-changwei/Automation-scripts-for-Aegi
]]

script_name="C Utilities"
script_description="Utilities v1.7"
script_description="Utilities v1.7.1"
script_author="chaaaaang"
script_version="1.7"
script_version="1.7.1"

include('karaskel.lua')
re = nil
Expand Down Expand Up @@ -39,6 +39,13 @@ local XYZ_2_Rec2020_MAT = {
{0.0176423, -0.0427767, 0.942241}
}

-- ZHO \u4e00-\u9fa5 \u3400-\u4db5
-- KOR \u3130-\u318f \uac00-\ud7a3
-- JPN \u0800-\u4e00
-- 0000-007f 0xxxxxxx ASCII
-- 0080-07ff 110xxxxx 10xxxxxx WESTERN EUROPE
-- 0800-ffff 1110xxxx 10xxxxxx 10xxxxxx

local dialog_config = {
{class="label",label="Options",x=0,y=0},--1
{class="dropdown",name="option",
Expand Down Expand Up @@ -250,25 +257,26 @@ function main(subtitle, selected, active)
local ae_timeU = 1000/result.ae_fps
local ae_timeS,ae_timeE = line.start_time,line.end_time
local ae_fin,ae_fout = result.ae_fin,result.ae_fout
local j,ki,ko = 1,1,1
local j,k,ki,ko = 1,tonumber(ae_mid),1,1

while ae_timeS+(j-0.5)*ae_timeU<ae_timeE do
subtitle.insert(li+j-1,line)
local new_line = subtitle[li+j-1]
new_line.start_time = ae_timeS + math.floor((j-1) * ae_timeU)
new_line.end_time = ae_timeS + math.floor(j * ae_timeU)

if j<10 then ae_mid = ae_mid:gsub("%d$",j)
elseif j<100 then ae_mid = ae_mid:gsub("%d%d$",j)
elseif j<1000 then ae_mid = ae_mid:gsub("%d%d%d$",j)
elseif j<10000 then ae_mid = ae_mid:gsub("%d%d%d%d$",j)
else ae_mid = ae_mid:gsub("%d%d%d%d%d$",j)
if k<10 then ae_mid = ae_mid:gsub("%d$",k)
elseif k<100 then ae_mid = ae_mid:gsub("%d%d$",k)
elseif k<1000 then ae_mid = ae_mid:gsub("%d%d%d$",k)
elseif k<10000 then ae_mid = ae_mid:gsub("%d%d%d%d$",k)
else ae_mid = ae_mid:gsub("%d%d%d%d%d$",k)
end
new_line.text = "{\\an7\\pos(0,0)\\bord0\\shad0\\fscx100\\fscy100\\1img("..ae_pre..ae_mid..ae_post..")\\p1}"
new_line.text = new_line.text..string.format("m 0 0 l %d 0 l %d %d l 0 %d",result.ae_w,result.ae_w,result.ae_h,result.ae_h)

subtitle[li+j-1] = new_line
j = j + 1
k = k + 1
end

if ae_fin>0 then
Expand Down Expand Up @@ -456,25 +464,25 @@ function main(subtitle, selected, active)
chs,eng = chs:gsub("{[^}]*}",""),eng:gsub("{[^}]*}","")
chs,eng = chs:gsub(" +",""),eng:gsub(" +","")
if result.dialog_blstyle=="zho\\Neng" then
if chs:match("[\128-\191]")~=nil and eng:match("[\128-\191]")==nil then
if chs:match("[\228-\233]")~=nil and chs:match("%a")==nil and eng:match("[\128-\191]")==nil then
else
line.actor = line.actor.."bilang "
log.bilang = log.bilang + 1
end
elseif result.dialog_blstyle=="zho\\Nany" then
if chs:match("[\128-\191]")~=nil and eng~="" then
if chs:match("[\228-\233]")~=nil and chs:match("%a")==nil and eng:match("[\228-\233]")==nil then
else
line.actor = line.actor.."bilang "
log.bilang = log.bilang + 1
end
elseif result.dialog_blstyle=="any\\Neng" then
if chs~="" and eng:match("[\128-\191]")==nil then
if chs:match("[\228-\233]")~=nil and eng:match("[\128-\191]")==nil then
else
line.actor = line.actor.."bilang "
log.bilang = log.bilang + 1
end
elseif result.dialog_blstyle=="any\\Nany" then
if chs~="" and eng~="" then
if chs:match("[\228-\233]")~=nil and eng:match("[\228-\233]")==nil then
else
line.actor = line.actor.."bilang "
log.bilang = log.bilang + 1
Expand Down Expand Up @@ -651,7 +659,7 @@ function main(subtitle, selected, active)
end
elseif result.option=="Separate Bilingual SUBS by \\N" then
linetext = linetext:gsub("^{}","")
linetext=linetext:gsub("([\128-\191][^ ]*) +([\1-\127]+)$","%1\\N%2")
linetext=linetext:gsub("([\228-\233][^ ]*) +([^\228-\233]+)$","%1\\N%2") -- 1110xxxx 10xxxxxx 10xxxxxx
elseif result.option=="SDR2HDR ColorGrading" then
linetext = linetext:gsub("^{}","")
linetext = linetext:gsub("(\\[1234]?v?c)&?H?(%x%x)(%x%x)(%x%x)&?",function (pre,b,g,r)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| C Merge Bilingual SUBS | v1.1 |
| C Jump | v1.0 |
| C Translation | v3.2 |
| C Utilities | v1.7 |
| C Utilities | v1.7.1 |
| * C Scaling Rotation Conflict Solution | v1.1 |
> 在Automation Manager Description栏中查看脚本版本信息
> 若你的脚本在上述表格中且无版本信息 可能需要考虑更新脚本
Expand Down Expand Up @@ -165,6 +165,8 @@
## __INF. 更新日志__
| Date | Script | Version | Detail |
|------|--------|---------|--------|
|2021.8.11|C Effect|1.1.1|bug修复|
|2021.8.8|C Utilities|1.7.1|优化中文匹配,AE导入支持非从1开始的序列|
|2021.8.7|Effect life game||一个小游戏|
|2021.8.7|C Effect|1.1|加快运行速度,简化无用参数|
|2021.8.4|C Change SUB resolution to match video PATCH|1.1|重大更新,完全重写了代码,无需经过自带的分辨率转换(精度低,有奇妙的bug),运行脚本后手动调整分辨率即可|
Expand Down
9 changes: 5 additions & 4 deletions with Yutils/C Effect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ goto my repository https://github.com/zhang-changwei/Automation-scripts-for-Aegi

--Script properties
script_name="C Effect"
script_description="Effect v1.1"
script_description="Effect v1.1.1"
script_author="chaaaaang"
script_version="1.1"
script_version="1.1.1"

local Yutils = require('Yutils')
include('karaskel.lua')
Expand Down Expand Up @@ -109,6 +109,7 @@ function main(subtitle, selected)
line.text = line.text:match("^{") and line.text or "{}"..line.text

-- Yutils
fontsize,scale_x,scale_y,spacing,angle = tonumber(fontsize),tonumber(scale_x),tonumber(scale_y),tonumber(spacing),tonumber(angle)
local font_handle = Yutils.decode.create_font(font,bold,italic,underline,strikeout,fontsize,scale_x/100,scale_y/100,spacing)
local shape = font_handle.text_to_shape(ltxtstripped)
local pixels = Yutils.shape.to_pixels(shape)
Expand Down Expand Up @@ -849,7 +850,7 @@ function position(ltext,line,xres,yres)
end

function positionL(angle,x,y,t,l,b,r)
angle = tonumber(angle)/180*math.pi
angle = angle/180*math.pi
local r1 = x + (r-x)*math.cos(angle) + (b-y)*math.sin(angle)
local r2 = x + (r-x)*math.cos(angle) - (y-t)*math.sin(angle)
local l1 = x - (x-l)*math.cos(angle) + (b-y)*math.sin(angle)
Expand All @@ -864,7 +865,7 @@ end

-- output relative position for Yutils
function posL2pos(angle,x,y,t,l,posx,posy)
angle = tonumber(angle)/180*math.pi
angle = angle/180*math.pi
return (posx-l) + (x-posx)*math.cos(angle)-(y-posy)*math.sin(angle),(posy-t) + (y-posy)*math.cos(angle)+(x-posx)*math.sin(angle)
end

Expand Down

0 comments on commit d520ecf

Please sign in to comment.