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

 找回密码
 新人加入
查看: 4583|回复: 1
打印 上一主题 下一主题

[tcaxLib] test the behavior of the CombinePixs function [复制链接]

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2011-12-19 21:15:47 |只看该作者 |倒序浏览
  1. # this script tests for the behavior of the very important function CombinePixs, which is used to composite PIXs into a single one
  2. # it can not only reduce the output size of the TCAS, but also can gain much convenience for manipulating PIXs, just consider of any
  3. # image manipulation software


  4. from tcaxPy import *

  5. def tcaxPy_Init():
  6.     GetHelp()
  7.     Pause()
  8.     global Font
  9.     global FontOut
  10.     #_Fs = GetVal(val_FontSize)
  11.     _FileName = GetVal(val_FontFileName)
  12.     _FaceID = GetVal(val_FaceID)
  13.     Font = InitFont(_FileName, _FaceID, 40, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(255, 0, 0), 0, False)
  14.     FontOut = InitFont(_FileName, _FaceID, 40, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 255, 0), 10, False)

  15. def tcaxPy_Fin():
  16.     FinFont(Font)
  17.     FinFont(FontOut)

  18. def tcaxPy_User():
  19.     file_name = GetVal(val_OutFile) + '.tcas'
  20.     fx_width = GetVal(val_ResolutionX)
  21.     fx_height = GetVal(val_ResolutionY)
  22.     fps = GetVal(val_FXFPS)
  23.     TCAS_FILE = CreateTcasFile(file_name, fx_width, fx_height, fps)
  24.     TCAS_BUF = []
  25.     for i in range(1):
  26.         dx = 200
  27.         dy = 200
  28.         
  29.         PIX1 = BlankPix(40, 40, MakeRGBA(255, 0, 0, 128))   # red
  30.         PIX2 = BlankPix(50, 50, MakeRGBA(0, 255, 0, 128))       # green
  31.         PIX3 = CombinePixs(PIX1, PIX2)       # green over red
  32.         PIX4 = CombinePixs(PIX2, PIX1)       # red over green
  33.         
  34.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx, dy, 0)
  35.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx, dy, 0)  # green over red
  36.         
  37.         tcas_main(TCAS_BUF, PIX3, 0, 10000, dx, dy + 100, 0)    # green over red
  38.         
  39.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 100, dy, 1)
  40.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 100, dy, 0)    # red over green
  41.         
  42.         tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 100, dy + 100, 0)  # red over green
  43.         
  44.         PIX1 = ((20, 30), PIX1[1], PIX1[2])     # add pos(20, 30) to the old PIX1
  45.         PIX2 = PIX2     # didn't change
  46.         PIX3 = CombinePixs(PIX1, PIX2)      # green over red
  47.         PIX4 = CombinePixs(PIX2, PIX1)      # red over green
  48.         
  49.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 200, dy, 0)
  50.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 200, dy, 0)    # green over red
  51.         
  52.         tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 200, dy + 100, 0)  # green over red
  53.         
  54.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 300, dy, 1)
  55.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 300, dy, 0)    # red over green
  56.         
  57.         tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 300, dy + 100, 0)  # red over green
  58.         
  59.         # round two
  60.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy, 0)
  61.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 400, dy, 0)    # green over red
  62.         
  63.         tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 400, dy + 100, 0)  # green over red
  64.         
  65.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy, 1)
  66.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 500, dy, 0)    # red over green
  67.         
  68.         tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 500, dy + 100, 0)  # red over green
  69.         
  70.         PIX1 = ((25, 35), PIX1[1], PIX1[2])     # add pos(25, 35) to the old PIX1
  71.         PIX1 = PixColorRGBA(PIX1, MakeRGBA(100, 0, 0, 255))
  72.         PIX2 = ((5, 5), PIX2[1], PIX2[2])     # add pos(5, 5) to the old PIX2
  73.         PIX2 = PixColorRGBA(PIX2, MakeRGBA(0, 100, 0, 255))
  74.         PIX3 = CombinePixs(PIX1, PIX2)      # green over red
  75.         PIX4 = CombinePixs(PIX2, PIX1)      # red over green
  76.         
  77.         tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 400, dy, 0)  # green over red
  78.         
  79.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy + 100, 0)
  80.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 400, dy + 100, 0)    # green over red
  81.         
  82.         tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 500, dy, 1)  # red over green, note that the layer should be at least 1, otherwise it will be covered by the red one (line: 63)
  83.         
  84.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy + 100, 1)
  85.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 500, dy + 100, 0)    # red over green
  86.         
  87.         
  88.         dx = 200
  89.         dy = 400
  90.         
  91.         PIX_t = TextPix(Font, 'E')
  92.         PIX_t = PixColorMul(PIX_t, 1, 1, 1, 0.5)    # red
  93.         PIX_o = TextPix(FontOut, 'E')
  94.         PIX_o = PixColorMul(PIX_o, 1, 1, 1, 0.5)    # green
  95.         PIX_c1 = CombinePixs(PIX_t, PIX_o)  # green over red
  96.         PIX_c2 = CombinePixs(PIX_o, PIX_t)  # red over green
  97.         
  98.         print(PIX_t[0])
  99.         print(PIX_o[0])
  100.         
  101.         tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx, dy, 0)
  102.         tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx, dy, 0)  # green over red
  103.         
  104.         tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx, dy + 100, 0)    # green over red
  105.         
  106.         tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 100, dy, 1)
  107.         tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 100, dy, 0)    # red over green
  108.         
  109.         tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 100, dy + 100, 0)  # red over green
  110.         
  111.         # round two
  112.         PIX2 = BlankPix(40, 40, MakeRGBA(0, 255, 0, 128))       # green
  113.         PIX_c1 = CombinePixs(PIX_t, PIX2)  # green over red
  114.         PIX_c2 = CombinePixs(PIX2, PIX_t)  # red over green
  115.         
  116.         tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 200, dy, 0)
  117.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 200, dy, 0)    # green over red
  118.         
  119.         tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx + 200, dy + 100, 0)  # green over red
  120.         
  121.         tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 300, dy, 1)
  122.         tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 300, dy, 0)    # red over green
  123.         
  124.         tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 300, dy + 100, 0)  # red over green
  125.         
  126.         PIX1 = BlankPix(40, 40, MakeRGBA(255, 0, 0, 128))       # red
  127.         PIX_c1 = CombinePixs(PIX_o, PIX1)  # red over green
  128.         PIX_c2 = CombinePixs(PIX1, PIX_o)  # green over red
  129.         
  130.         tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 400, dy, 0)
  131.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy, 0)    # green over red
  132.         
  133.         tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx + 400, dy + 100, 0)  # green over red
  134.         
  135.         tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 500, dy, 1)
  136.         tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy, 0)    # red over green
  137.         
  138.         tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 500, dy + 100, 0)  # red over green
  139.         
  140.     WriteTcasFile(TCAS_FILE, TCAS_BUF)     # write the buffer in memory to the file
  141.     FinTcasFile(TCAS_FILE)
复制代码

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 2011-12-19 21:16:53 |只看该作者
screenshot.png
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-22 23:11

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH