kara-templater retime() function implemented, tested and working :)

Originally committed to SVN as r1226.
This commit is contained in:
Niels Martin Hansen 2007-06-16 21:57:14 +00:00
parent b2c04484f2
commit 354f96c081
3 changed files with 71 additions and 2 deletions

View file

@ -256,6 +256,47 @@ function apply_templates(meta, styles, subs, templates)
} }
tenv.tenv = tenv tenv.tenv = tenv
tenv.retime = function(mode, addstart, addend)
local line, syl = tenv.line, tenv.syl
local newstart, newend = line.start_time, line.end_time
addstart = addstart or 0
addend = addend or 0
if mode == "syl" then
newstart = line.start_time + syl.start_time + addstart
newend = line.start_time + syl.end_time + addend
elseif mode == "presyl" then
newstart = line.start_time + syl.start_time + addstart
newend = line.start_time + syl.start_time + addend
elseif mode == "postsyl" then
newstart = line.start_time + syl.end_time + addstart
newend = line.start_time + syl.end_time + addend
elseif mode == "preline" then
newstart = line.start_time + addstart
newend = line.start_time + addend
elseif mode == "postline" then
newstart = line.end_time + addstart
newend = line.end_time + addend
elseif mode == "start2syl" then
newstart = line.start_time + addstart
newend = line.start_time + syl.start_time + addend
elseif mode == "syl2end" then
newstart = line.start_time + syl.end_time + addstart
newend = line.end_time + addend
elseif mode == "set" or mode == "abs" then
newstart = addstart
newend = addend
elseif mode == "sylpct" then
newstart = line.start_time + syl.start_time + addstart*syl.duration/100
newend = line.start_time + syl.start_time + addend*syl.duration/100
-- wishlist: something for fade-over effects,
-- "time between previous line and this" and
-- "time between this line and next"
end
line.start_time = newstart
line.end_time = newend
return ""
end
-- run all run-once code snippets -- run all run-once code snippets
for k, t in pairs(templates.once) do for k, t in pairs(templates.once) do
assert(t.code, "WTF, a 'once' template without code?") assert(t.code, "WTF, a 'once' template without code?")
@ -375,8 +416,7 @@ function apply_line(meta, styles, subs, line, templates, tenv)
tenv.orgline = line tenv.orgline = line
tenv.line = nil tenv.line = nil
tenv.syl = nil tenv.syl = nil
tenv.char = nil tenv.basesyl = nil
tenv.furi = nil
-- Apply all line templates -- Apply all line templates
aegisub.debug.out(5, "Running line templates\n") aegisub.debug.out(5, "Running line templates\n")

View file

@ -0,0 +1,29 @@
[Script Info]
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 640
PlayResY: 480
Video Aspect Ratio: 0
Video Zoom: 8
Video Position: 500
Last Style Storage: Default
Video File: ?dummy:50.000000:1000:640:480:226:221:236:c
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,50,&H00FFFFFF,&H0000FFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,0,5,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("abs",1000,2000)!{\pos($x,$y)\1c&H0000FF&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("preline",-100)!{\pos($x,$y)\1c&H000000&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("start2syl")!{\pos($x,$y)\1c&HFF0000&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("presyl",-200,0)!{\pos($x,$y)\1a&HFF&\3c&H0000FF&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("syl")!{\pos($x,$y)\1c&H00FF00&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("postsyl",0,200)!{\pos($x,$y)\1a&HFF&\3c&H00FF00&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("syl2end",200,0)!{\pos($x,$y)\1c&HFF00FF&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("postline",0,100)!{\pos($x,$y)\1c&H00FFFF&}
Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,template noblank,!retime("sylpct",50,100)!{\pos($center,$middle)\an5\1a&HFF&\3c&HFFFFFF&\fscy300\t(\3a&HFF&)}
Dialogue: 0,0:00:10.00,0:00:11.00,Default,,0000,0000,0000,,{\k30}ha{\k20}hi{\k50}ho
Dialogue: 0,0:00:11.00,0:00:16.00,Default,,0000,0000,0000,,

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB