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

标题: 主要是MOD的tag 不是很實用 自己都沒怎麼用過 [打印本页]

作者: saiyaku    时间: 2011-10-22 19:38:44     标题: 主要是MOD的tag 不是很實用 自己都沒怎麼用過

  1. # -*- coding: utf-8 -*-


  2. from math   import *
  3. from random import *
  4. from tcaxPy import *

  5. ################MOD TAG######################

  6. def frs(a):
  7.     FRS = '\\frs' + str(a)
  8.     return FRS

  9. def fsvp(a):
  10.     FSVP = '\\fsvp' + str(a)
  11.     return FSVP

  12. def distort(u1,v1,u2,v2,u3,v3):
  13.     X = [u1,v1,u2,v2,u3,v3]
  14.     DISTORT = '\\distort('+','.join(str(x) for x in X)+')'
  15.     return DISTORT

  16. def z(a):
  17.     Z = '\\z'+str(a)
  18.     return Z

  19. def rnd(a):
  20.     RND = '\\rnd' + str(a)
  21.     return RND

  22. def rndx(a):
  23.     RNDX = '\\rndx' + str(a)
  24.     return RNDX

  25. def rndy(a):
  26.     RNDY = '\\rndy' + str(a)
  27.     return RNDY

  28. def rndz(a):
  29.     RNDZ = '\\rndz' + str(a)
  30.     return RNDZ

  31. def vc1(ltc,rtc,lbc,rbc):
  32.     X = [ltc,rtc,lbc,rbc]
  33.     VC1 = '\\1vc('+','.join('&H'+str(x)+'&' for x in X )+')'
  34.     return VC1

  35. def vc2(ltc,rtc,lbc,rbc):
  36.     X = [ltc,rtc,lbc,rbc]
  37.     VC2 = '\\2vc('+','.join('&H'+str(x)+'&' for x in X )+')'
  38.     return VC2

  39. def vc3(ltc,rtc,lbc,rbc):
  40.     X = [ltc,rtc,lbc,rbc]
  41.     VC3 = '\\3vc('+','.join('&H'+str(x)+'&' for x in X )+')'
  42.     return VC3

  43. def vc4(ltc,rtc,lbc,rbc):
  44.     X = [ltc,rtc,lbc,rbc]
  45.     VC4 = '\\4vc('+','.join('&H'+str(x)+'&' for x in X )+')'
  46.     return VC4
  47.          
  48. def va1(ltt,rtt,lbt,rbt):        
  49.     X = [ltt,rtt,lbt,rbt]
  50.     VA1 = '\\1va('+','.join('&H'+ FmtHex(x) +'&' for x in X )+')'
  51.     return VA1

  52. def va2(ltt,rtt,lbt,rbt):        
  53.     X = [ltt,rtt,lbt,rbt]
  54.     VA2 = '\\2va('+','.join('&H'+ FmtHex(x) +'&' for x in X )+')'
  55.     return VA2

  56. def va3(ltt,rtt,lbt,rbt):        
  57.     X = [ltt,rtt,lbt,rbt]
  58.     VA3 = '\\3va('+','.join('&H'+ FmtHex(x) +'&' for x in X )+')'
  59.     return VA3

  60. def va4(ltt,rtt,lbt,rbt):        
  61.     X = [ltt,rtt,lbt,rbt]
  62.     VA4 = '\\4va('+','.join('&H'+ FmtHex(x) +'&' for x in X )+')'
  63.     return VA4

  64. def img1(pngpath,xoffset = None,yoffset = None):
  65.     X = [pngpath,xoffset,yoffset]
  66.     IMG1 = '\\1img('+','.join(str(x) for x in X if x != None ) + ')'
  67.     return IMG1

  68. def mover(x1,y1,x2,y2,angle1,angle2,radius1,radius2,t1 = None,t2 = None) :
  69.     A1 = int(angle1)
  70.     A2 = int(angle2)
  71.     R1 = int(radius1)
  72.     R2 = int(radius2)
  73.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2):
  74.         X1 = int(x1)
  75.         Y1 = int(y1)
  76.         X2 = int(x2)
  77.         Y2 = int(y2)
  78.     else:
  79.         X1 = format(x1, '.2f')
  80.         Y1 = format(y1, '.2f')
  81.         X2 = format(x2, '.2f')
  82.         Y2 = format(y2, '.2f')
  83.     X = [X1,Y1,X2,Y2,A1,A2,R1,R2,t1,t2]   
  84.     MOVER = '\\mover('+','.join(str(x) for x in X if x != None) + ')'
  85.     return MOVER

  86. def moves3(x1,y1,x2,y2,x3,y3,t1 = None,t2 = None):
  87.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2):
  88.         X1 = int(x1)
  89.         Y1 = int(y1)
  90.         X2 = int(x2)
  91.         Y2 = int(y2)
  92.         X3 = int(x3)
  93.         Y3 = int(y3)
  94.     else:
  95.         X1 = format(x1, '.2f')
  96.         Y1 = format(y1, '.2f')
  97.         X2 = format(x2, '.2f')
  98.         Y2 = format(y2, '.2f')
  99.         X3 = format(x3, '.2f')
  100.         Y3 = format(y3, '.2f')
  101.     X = [X1,Y1,X2,Y2,X3,Y3,t1,t2]
  102.     MOVES3 = '\\moves3('+','.join(str(x) for x in X if x != None) + ')'
  103.     return MOVES3

  104. def moves4(x1,y1,x2,y2,x3,y3,x4,y4,t1 = None,t2 = None):
  105.     if x1 == int(x1) and y1 == int(y1) and x2 == int(x2) and y2 == int(y2):
  106.         X1 = int(x1)
  107.         Y1 = int(y1)
  108.         X2 = int(x2)
  109.         Y2 = int(y2)
  110.         X3 = int(x3)
  111.         Y3 = int(y3)
  112.         X4 = int(x4)
  113.         Y4 = int(y4)        
  114.     else:
  115.         X1 = format(x1, '.2f')
  116.         Y1 = format(y1, '.2f')
  117.         X2 = format(x2, '.2f')
  118.         Y2 = format(y2, '.2f')
  119.         X3 = format(x3, '.2f')
  120.         Y3 = format(y3, '.2f')
  121.         X4 = format(x4, '.2f')
  122.         Y4 = format(y4, '.2f')        
  123.     X = [X1,Y1,X2,Y2,X3,Y3,X4,Y4,t1,t2]
  124.     MOVES4 = '\\moves4('+','.join(str(x) for x in X if x != None) + ')'
  125.     return MOVES4

  126. def jitter(left,right,up,down,period,seed = None):
  127.     X = [left,right,up,down,period,seed]
  128.     JITTER = '\\jitter('+ ','.join(str(x) for x in X if x != None) + ')'
  129.     return JITTER

  130. def movevc(x1,y1,x2 = None,y2 = None,t1 = None,t2 = None):
  131.     X = [x1,y1,x2,y2,t1,t2]
  132.     MOVEVC = '\\movevc('+','.join(str(x) for x in X if x != None) + ')'
  133.     return MOVEVC
  134. ###################################### EXTRA FUNCTION #########################################################

  135. def alt(BT,ET, t = 100 , FX1 = alpha(255), FX2 = alpha(0), offset = 0, a1 = None,a2 = None):         #交替t效果 默认闪烁
  136.     n = 1
  137.     T = ''
  138.     for i in range(int(t)+ int(offset),(ET-BT)*10,int(t)):
  139.         if n % 2 != 0 :   
  140.             X1 = [str(i-t),str(i),a1,FX1]
  141.             T1 = '\\t('+','.join(str(x) for x in X1 if x != None)+ ')'
  142.             T += T1
  143.         else:
  144.             X2 = [str(i-t),str(i),a2,FX2]
  145.             T2 = '\\t('+','.join(str(x) for x in X2 if x != None)+ ')'
  146.             T += T2
  147.         n += 1   
  148.     return T



  149. #################### ASS DRAW ############################

  150. def pbri(n = 4):    #绘制十字闪光
  151.     BRI = 'm 0 100 l 1 1 100 0 1 -1 0 -100 -1 -1 -100 0 -1 1 c m 6 6 s 6 -6 -6 -6 -6 6 c'
  152.     PBRI = '{\\p'+str(n)+'}'+BRI
  153.     return PBRI

  154. def pflame(n = 4):    #绘制火焰
  155.     FLAME = 'm 0 9 b 3 3 6 3 9 6 b 12 9 15 2 19 4 b 24 5 23 11 18 13 b 15 13 13 13 10 10 b 6 6 2 6 0 10'
  156.     PFLAME = '{\\p'+str(n)+'}'+FLAME
  157.     return PFLAME

  158. def poval(n = 4):    #绘制椭圆
  159.     OVAL = 'm 50 0 b 100 0 100 100 50 100 b 0 100 0 0 50 0'
  160.     POVAL = '{\\p'+str(n)+'}'+ OVAL
  161.     return POVAL

  162. def pdrop(n = 4):     #绘制水滴
  163.     DROP = 'm 0 -5 b -8 7 8 7 0 -5'
  164.     PDROP = '{\\p'+str(n)+'}'+ DROP
  165.     return PDROP

  166. def psakura(n = 2):    #绘制樱花
  167.     SAKURA = 'm 3 9 b -6 9 -7 -7 2 -12 7 -8 6 1 3 9'
  168.     PSAKURA = '{\\p'+str(n)+'}'+ SAKURA
  169.     return PSAKURA

  170. def phane(n = 1):      #绘制羽毛
  171.     HANE = 'm 12 -15 b 12 -12 11 -10 9 -7 9 -6 9 -5 9 -4 11 -5 11 -3 8 -3 l 9 -2 6 -1 5 0 3 -2 b -3 12 -20 11 -25 6 -26 5 -25 3 -23 3 -20 3 -9 5 2 -3 l -1 -4 b -1 -6 1 -6 2 -6 2 -7 1 -8 1 -9 2 -9 4 -8 5 -8 4 -10 4 -12 5 -11 6 -11 6 -9 7 -8 9 -10 10 -13 10 -16 c'
  172.     PHANE = '{\\p'+str(n)+'}'+ HANE
  173.     return PHANE
复制代码

作者: milkyjing    时间: 2011-10-22 20:17:08

提示: 本代码建议保存为 s.py, 前面有些脚本用到了这个库. 文件存放位置, 最简单的就是直接拖到工程文件夹下... (不需要其他任何改动)

补充: 建议使用 utf-8编码保存.
作者: 四月一日 君寻    时间: 2011-12-15 15:54:49

求教 def movevc(x1,y1,x2 = None,y2 = None,t1 = None,t2 = None):
    X = [x1,y1,x2,y2,t1,t2]
    MOVEVC = '\\movevc('+','.join(str(x) for x in X if x != None) + ')'
    return MOVEVC     的用法……试过几次失败……
作者: saiyaku    时间: 2011-12-15 17:19:43

七海の游风 发表于 2011-12-15 15:54
求教 def movevc(x1,y1,x2 = None,y2 = None,t1 = None,t2 = None):
    X = [x1,y1,x2,y2,t1,t2]
    MOVE ...

mod 我也沒用過 函數的用法 就是和一般tag 一樣

movevc(x1,y1,x2,y2,t1,t2)

和 move 感覺差不多吧 t1,t2 可以不寫
作者: saiyaku    时间: 2011-12-15 17:29:33

最好是 如 milk 說的 整個腳本 保存為 s.py
丟入tcax 根目錄
然後 你的py腳本開頭加上 from s import *
然後就隨便利用裏面函數了
作者: 四月一日 君寻    时间: 2011-12-15 18:12:19

saiyaku 发表于 2011-12-15 17:29
最好是 如 milk 說的 整個腳本 保存為 s.py
丟入tcax 根目錄
然後 你的py腳本開頭加上 from s import *

哦 谢谢sai大
作者: Mirael    时间: 2012-3-10 21:06:56

How to correctly implement this macro?
I use vsfiltermod for creating karaoke at lua.

I saved the file in "D: \ Karaoke \ tcax \ extLibs" and to create a script in tcax
I gave this statement:

"from tcaxPy import *
from Tags_mod import *"

But as usual I found the error. ;/

Clipboard01.png

图片附件: Clipboard01.png (2012-3-10 21:05:24, 97.92 KB) / 下载次数 1902
http://tcax.org/forum.php?mod=attachment&aid=Mzk0fDk2MDVmZTU1fDE3MzI0NjEzMDh8MHww


作者: milkyjing    时间: 2012-3-10 21:24:11

Mirael 发表于 2012-3-10 21:06
How to correctly implement this macro?
I use vsfiltermod for creating karaoke at lua.

There is a little Python thing... you should use extLibs.Tags_mod, like

from extLibs.Tags_mod import *
作者: Mirael    时间: 2012-3-10 21:44:58

A man learns by the end of life. ^ ^
Thank you. :)
But:
3.png

图片附件: 3.png (2012-3-10 21:44:44, 98.38 KB) / 下载次数 1952
http://tcax.org/forum.php?mod=attachment&aid=Mzk3fDFjN2I2YjE4fDE3MzI0NjEzMDh8MHww


作者: milkyjing    时间: 2012-3-10 21:51:47

Mirael 发表于 2012-3-10 21:44
A man learns by the end of life. ^ ^
Thank you. :)
But:


this probably be an encoding issue, try to copy the codes above, paste to the notepad, then save as "utf-8".


作者: Mirael    时间: 2012-3-10 22:17:12

本帖最后由 Mirael 于 2012-3-12 18:08 编辑

Notepad++ has automatic saving of character encoding format to UTF-8.
But once I copied the script and it works. :)


图片附件: 1.png (2012-3-12 18:00:13, 990.84 KB) / 下载次数 2041
http://tcax.org/forum.php?mod=attachment&aid=NDI3fGZkNGI4NjUzfDE3MzI0NjEzMDh8MHww


作者: milkyjing    时间: 2012-3-10 22:20:02

Mirael 发表于 2012-3-10 22:17
Notepad++ has automatic saving of character encoding format to UTF-8.
But once I copied the script a ...

It works? Good.

p.s. I have replied your last PM.




欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/) Powered by Discuz! X2