TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua

 找回密码
 加入社区
查看: 211|回复: 0

tcax.py Version 8.0.0.2 [复制链接]

Rank: 5Rank: 5

发表于 2018-12-9 01:29:30 |显示全部楼层
本帖最后由 mccoy39082 于 2018-12-9 02:47 编辑

saiyaku的基础上增加了fsp标签和VSFilterMod标签的支持。

脚本文件: tcaxPy.py (46.24 KB, 下载次数: 9)
差分文件: diff_tcaxPy_tcaxPy_Dec-09-2018 02-39.zip (25.67 KB, 下载次数: 9)
  1. def fsp(a):
  2.     if a == int(a):
  3.         A = str(int(a))
  4.     else:
  5.         A = str(format(a, '.2f'))
  6.     return '\\fsp{0}'.format(A)

  7. def fsvp(a):
  8.     if a == int(a):
  9.         A = str(int(a))
  10.     else:
  11.         A = str(format(a, '.2f'))
  12.     return '\\fsvp{0}'.format(A)

  13. def frs(a):
  14.     if a == int(a):
  15.         A = str(int(a))
  16.     else:
  17.         A = str(format(a, '.2f'))
  18.     return '\\frs{0}'.format(A)

  19. def z(a):
  20.     if a == int(a):
  21.         A = str(int(a))
  22.     else:
  23.         A = str(format(a, '.2f'))
  24.     return '\\z{0}'.format(A)

  25. def distort(u1, v1, u2, v2, u3, v3):
  26.     if u1 == int(u1) and v1 == int(v1) and u2 == int(u2) and v2 == int(v2) and u3 == int(u3) and v3 == int(v3):
  27.         U1 = str(int(u1))
  28.         V1 = str(int(v1))
  29.         U2 = str(int(u2))
  30.         V2 = str(int(v2))
  31.         U3 = str(int(u3))
  32.         V3 = str(int(v3))
  33.     else:
  34.         U1 = str(format(u1, '.2f'))
  35.         V1 = str(format(v1, '.2f'))
  36.         U2 = str(format(u2, '.2f'))
  37.         V2 = str(format(v2, '.2f'))
  38.         U3 = str(format(u3, '.2f'))
  39.         V3 = str(format(v3, '.2f'))
  40.     return '\\distort({0},{1},{2},{3},{4},{5})'.format(U1, V1, U2, V2, U3, V3)

  41. def rnd(a):
  42.     if a == int(a):
  43.         A = str(int(a))
  44.     else:
  45.         A = str(format(a, '.2f'))
  46.     return '\\rnd{0}'.format(A)

  47. def rndx(a):
  48.     if a == int(a):
  49.         A = str(int(a))
  50.     else:
  51.         A = str(format(a, '.2f'))
  52.     return '\\rndx{0}'.format(A)

  53. def rndy(a):
  54.     if a == int(a):
  55.         A = str(int(a))
  56.     else:
  57.         A = str(format(a, '.2f'))
  58.     return '\\rndy{0}'.format(A)

  59. def rndz(a):
  60.     if a == int(a):
  61.         A = str(int(a))
  62.     else:
  63.         A = str(format(a, '.2f'))
  64.     return '\\rndz{0}'.format(A)

  65. def img1(path, x, y):
  66.     if x == int(x) and y == int(y):
  67.         X = str(int(x))
  68.         Y = str(int(y))
  69.     else:
  70.         X = str(format(x, '.2f'))
  71.         Y = str(format(y, '.2f'))
  72.     return '\\1img({0},{1},{2})'.format(abspath(path), X, Y)

  73. def vcolor1(ct1, ct2, cb1, cb2): # note that c is a RGB string
  74.     return '\\1vc(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(ct1, ct2, cb1, cb2)

  75. def vcolor2(ct1, ct2, cb1, cb2):
  76.     return '\\2vc(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(ct1, ct2, cb1, cb2)

  77. def vcolor3(ct1, ct2, cb1, cb2):
  78.     return '\\3vc(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(ct1, ct2, cb1, cb2)

  79. def vcolor4(ct1, ct2, cb1, cb2):
  80.     return '\\4vc(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(ct1, ct2, cb1, cb2)

  81. def valpha1(at1, at2, ab1, ab2):
  82.     return '\\1va(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(FmtHex(at1), FmtHex(at2), FmtHex(ab1), FmtHex(ab2))

  83. def valpha2(at1, at2, ab1, ab2):
  84.     return '\\2va(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(FmtHex(at1), FmtHex(at2), FmtHex(ab1), FmtHex(ab2))

  85. def valpha3(at1, at2, ab1, ab2):
  86.     return '\\3va(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(FmtHex(at1), FmtHex(at2), FmtHex(ab1), FmtHex(ab2))

  87. def valpha4(at1, at2, ab1, ab2):
  88.     return '\\4va(&H{0}&,&H{1}&,&H{2}&,&H{3}&)'.format(FmtHex(at1), FmtHex(at2), FmtHex(ab1), FmtHex(ab2))

  89. def mover(x1, y1, x2, y2, a1, a2, r1, r2, t1 = None, t2 = None):
  90.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2) and a1 == int(a1) and a2 == int(a2):
  91.         X1 = str(int(x1))
  92.         Y1 = str(int(y1))
  93.         X2 = str(int(x2))
  94.         Y2 = str(int(y2))
  95.         A1 = str(int(a1))
  96.         A2 = str(int(a2))
  97.         R1 = str(int(r1))
  98.         R2 = str(int(r2))
  99.     else:
  100.         X1 = str(format(x1, '.2f'))
  101.         Y1 = str(format(y1, '.2f'))
  102.         X2 = str(format(x2, '.2f'))
  103.         Y2 = str(format(y2, '.2f'))
  104.         A1 = str(format(a1, '.2f'))
  105.         A2 = str(format(a2, '.2f'))
  106.         R1 = str(format(r1, '.2f'))
  107.         R2 = str(format(r2, '.2f'))
  108.     if t2 == None:
  109.         return '\\mover({0},{1},{2},{3},{4},{5},{6},{7})'.format(X1, Y1, X2, Y2, A1, A2, R1, R2)
  110.     else:
  111.         return '\\mover({0},{1},{2},{3},{4},{5},{6},{7},{8},{9})'.format(X1, Y1, X2, Y2, A1, A2, R1, R2, int(t1), int(t2))

  112. def moves3(x1, y1, x2, y2, x3, y3, t1 = None, t2 = None):
  113.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2) and x3 == int(x3) and y3 == int(y3):
  114.         X1 = str(int(x1))
  115.         Y1 = str(int(y1))
  116.         X2 = str(int(x2))
  117.         Y2 = str(int(y2))
  118.         X3 = str(int(x3))
  119.         Y3 = str(int(y3))
  120.     else:
  121.         X1 = str(format(x1, '.2f'))
  122.         Y1 = str(format(y1, '.2f'))
  123.         X2 = str(format(x2, '.2f'))
  124.         Y2 = str(format(y2, '.2f'))
  125.         X3 = str(format(x3, '.2f'))
  126.         Y3 = str(format(y3, '.2f'))
  127.     if t2 == None:
  128.         return '\\moves3({0},{1},{2},{3},{4},{5})'.format(X1, Y1, X2, Y2, X3, Y3)
  129.     else:
  130.         return '\\moves3({0},{1},{2},{3},{4},{5},{6},{7})'.format(X1, Y1, X2, Y2, X3, Y3, int(t1), int(t2))

  131. def moves4(x1, y1, x2, y2, x3, y3, x4, y4, t1 = None, t2 = None):
  132.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2) and x3 == int(x3) and y3 == int(y3) and  x4 == int(x4) and y4 == int(y4):
  133.         X1 = str(int(x1))
  134.         Y1 = str(int(y1))
  135.         X2 = str(int(x2))
  136.         Y2 = str(int(y2))
  137.         X3 = str(int(x3))
  138.         Y3 = str(int(y3))
  139.         X4 = str(int(x4))
  140.         Y4 = str(int(y4))
  141.     else:
  142.         X1 = str(format(x1, '.2f'))
  143.         Y1 = str(format(y1, '.2f'))
  144.         X2 = str(format(x2, '.2f'))
  145.         Y2 = str(format(y2, '.2f'))
  146.         X3 = str(format(x3, '.2f'))
  147.         Y3 = str(format(y3, '.2f'))
  148.         X4 = str(format(x4, '.2f'))
  149.         Y4 = str(format(y4, '.2f'))
  150.     if t2 == None:
  151.         return '\\moves4({0},{1},{2},{3},{4},{5},{6},{7})'.format(X1, Y1, X2, Y2, X3, Y3, X4, Y4)
  152.     else:
  153.         return '\\moves4({0},{1},{2},{3},{4},{5},{6},{7},{8},{9})'.format(X1, Y1, X2, Y2, X3, Y3, X4, Y4, int(t1), int(t2))

  154. def movevc(x1, y1, x2, y2, t1 = None, t2 = None):
  155.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2):
  156.         X1 = str(int(x1))
  157.         Y1 = str(int(y1))
  158.         X2 = str(int(x2))
  159.         Y2 = str(int(y2))
  160.     else:
  161.         X1 = str(format(x1, '.2f'))
  162.         Y1 = str(format(y1, '.2f'))
  163.         X2 = str(format(x2, '.2f'))
  164.         Y2 = str(format(y2, '.2f'))
  165.     if t2 == None:
  166.         return '\\moves3({0},{1},{2},{3},{4},{5})'.format(X1, Y1, X2, Y2)
  167.     else:
  168.         return '\\moves3({0},{1},{2},{3},{4},{5},{6},{7})'.format(X1, Y1, X2, Y2, int(t1), int(t2))

  169. def jitter(left, right, top, bottom, period, seed=None):
  170.     if left == int(left) and right == int(right) and top == int(top) and bottom == int(bottom) and period == int(period):
  171.         L = str(int(left))
  172.         R = str(int(right))
  173.         T = str(int(top))
  174.         B = str(int(bottom))
  175.         P = str(int(period))
  176.     else:
  177.         L = str(format(left,   '.2f'))
  178.         R = str(format(right,  '.2f'))
  179.         T = str(format(top,    '.2f'))
  180.         B = str(format(bottom, '.2f'))
  181.         P = str(format(period, '.2f'))
  182.     if seed == None:
  183.         return '\\jitter({0},{1},{2},{3},{4})'.format(L, R, T, B, P)
  184.     else:
  185.         if seed == int(seed):
  186.             S = str(int(seed))
  187.         else:
  188.             S = str(format(seed, '.2f'))
  189.         return '\\jitter({0},{1},{2},{3},{4},{5})'.format(L, R, T, B, P, S)
复制代码
1

查看全部评分

您需要登录后才可以回帖 登录 | 加入社区

GitHub|TCAX 主页

GMT+8, 2019-12-16 00:20

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH