Fix fade feature for bilibili positioned comments

This commit is contained in:
Star Brilliant 2013-11-24 13:04:44 +08:00
parent 2f8f4cf63f
commit 32d2838527

View File

@ -303,8 +303,12 @@ def WriteCommentBilibiliPositioned(f, c, width, height, styleid):
styles.append('\\3c&HFFFFFF&')
if from_alpha == to_alpha:
styles.append('\\alpha&H%02X' % from_alpha)
elif (from_alpha, to_alpha) == (255, 0):
styles.append('\\fad(%s,0)' % (lifetime*1000))
elif (from_alpha, to_alpha) == (0, 255):
styles.append('\\fad(0, %s)' % (lifetime*1000))
else:
styles.append('\\fade(%(from_alpha)s,%(to_alpha)s,%(to_alpha)s,%(start_time)s,%(end_time)s,%(end_time)s,%(end_time)s)' % {'from_alpha': from_alpha, 'to_alpha': to_alpha, 'start_time': delay, 'end_time': delay+duration})
styles.append('\\fade(%(from_alpha)s,%(to_alpha)s,%(to_alpha)s,0,%(end_time)s,%(end_time)s,%(end_time)s)' % {'from_alpha': from_alpha, 'to_alpha': to_alpha, 'end_time': lifetime*1000})
if isborder == 'false':
styles.append('\\bord0')
f.write('Dialogue: -1,%(start)s,%(end)s,%(styleid)s,,0000,0000,0000,,{%(styles)s}%(text)s\n' % {'start': ConvertTimestamp(c[0]), 'end': ConvertTimestamp(c[0]+lifetime), 'styles': ''.join(styles), 'text': text, 'styleid': styleid})