- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11740
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
- # this script tests for the behavior of the very important function CombinePixs, which is used to composite PIXs into a single one
- # it can not only reduce the output size of the TCAS, but also can gain much convenience for manipulating PIXs, just consider of any
- # image manipulation software
- from tcaxPy import *
- def tcaxPy_Init():
- GetHelp()
- Pause()
- global Font
- global FontOut
- #_Fs = GetVal(val_FontSize)
- _FileName = GetVal(val_FontFileName)
- _FaceID = GetVal(val_FaceID)
- Font = InitFont(_FileName, _FaceID, 40, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(255, 0, 0), 0, False)
- FontOut = InitFont(_FileName, _FaceID, 40, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 255, 0), 10, False)
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontOut)
- def tcaxPy_User():
- file_name = GetVal(val_OutFile) + '.tcas'
- fx_width = GetVal(val_ResolutionX)
- fx_height = GetVal(val_ResolutionY)
- fps = GetVal(val_FXFPS)
- TCAS_FILE = CreateTcasFile(file_name, fx_width, fx_height, fps)
- TCAS_BUF = []
- for i in range(1):
- dx = 200
- dy = 200
-
- PIX1 = BlankPix(40, 40, MakeRGBA(255, 0, 0, 128)) # red
- PIX2 = BlankPix(50, 50, MakeRGBA(0, 255, 0, 128)) # green
- PIX3 = CombinePixs(PIX1, PIX2) # green over red
- PIX4 = CombinePixs(PIX2, PIX1) # red over green
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx, dy, 0)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX3, 0, 10000, dx, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 100, dy, 1)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 100, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 100, dy + 100, 0) # red over green
-
- PIX1 = ((20, 30), PIX1[1], PIX1[2]) # add pos(20, 30) to the old PIX1
- PIX2 = PIX2 # didn't change
- PIX3 = CombinePixs(PIX1, PIX2) # green over red
- PIX4 = CombinePixs(PIX2, PIX1) # red over green
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 200, dy, 0)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 200, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 200, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 300, dy, 1)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 300, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 300, dy + 100, 0) # red over green
-
- # round two
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy, 0)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 400, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 400, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy, 1)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 500, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX4, 0, 10000, dx + 500, dy + 100, 0) # red over green
-
- PIX1 = ((25, 35), PIX1[1], PIX1[2]) # add pos(25, 35) to the old PIX1
- PIX1 = PixColorRGBA(PIX1, MakeRGBA(100, 0, 0, 255))
- PIX2 = ((5, 5), PIX2[1], PIX2[2]) # add pos(5, 5) to the old PIX2
- PIX2 = PixColorRGBA(PIX2, MakeRGBA(0, 100, 0, 255))
- PIX3 = CombinePixs(PIX1, PIX2) # green over red
- PIX4 = CombinePixs(PIX2, PIX1) # red over green
-
- tcas_main(TCAS_BUF, PIX3, 0, 10000, dx + 400, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy + 100, 0)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 400, dy + 100, 0) # green over red
-
- 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)
-
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy + 100, 1)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 500, dy + 100, 0) # red over green
-
-
- dx = 200
- dy = 400
-
- PIX_t = TextPix(Font, 'E')
- PIX_t = PixColorMul(PIX_t, 1, 1, 1, 0.5) # red
- PIX_o = TextPix(FontOut, 'E')
- PIX_o = PixColorMul(PIX_o, 1, 1, 1, 0.5) # green
- PIX_c1 = CombinePixs(PIX_t, PIX_o) # green over red
- PIX_c2 = CombinePixs(PIX_o, PIX_t) # red over green
-
- print(PIX_t[0])
- print(PIX_o[0])
-
- tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx, dy, 0)
- tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 100, dy, 1)
- tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 100, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 100, dy + 100, 0) # red over green
-
- # round two
- PIX2 = BlankPix(40, 40, MakeRGBA(0, 255, 0, 128)) # green
- PIX_c1 = CombinePixs(PIX_t, PIX2) # green over red
- PIX_c2 = CombinePixs(PIX2, PIX_t) # red over green
-
- tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 200, dy, 0)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 200, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx + 200, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_t, 0, 10000, dx + 300, dy, 1)
- tcas_main(TCAS_BUF, PIX2, 0, 10000, dx + 300, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 300, dy + 100, 0) # red over green
-
- PIX1 = BlankPix(40, 40, MakeRGBA(255, 0, 0, 128)) # red
- PIX_c1 = CombinePixs(PIX_o, PIX1) # red over green
- PIX_c2 = CombinePixs(PIX1, PIX_o) # green over red
-
- tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 400, dy, 0)
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 400, dy, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_c1, 0, 10000, dx + 400, dy + 100, 0) # green over red
-
- tcas_main(TCAS_BUF, PIX_o, 0, 10000, dx + 500, dy, 1)
- tcas_main(TCAS_BUF, PIX1, 0, 10000, dx + 500, dy, 0) # red over green
-
- tcas_main(TCAS_BUF, PIX_c2, 0, 10000, dx + 500, dy + 100, 0) # red over green
-
- WriteTcasFile(TCAS_FILE, TCAS_BUF) # write the buffer in memory to the file
- FinTcasFile(TCAS_FILE)
复制代码 |
|