| 
UID3积分8169帖子259主题68论坛币5016 威望54 EP值2533 MP值20 阅读权限200注册时间2011-8-3在线时间1097 小时最后登录2022-10-8
 
   
 | 
| 之前游風君問了一下 寫了這個例子 還是比較建議大家直接用tcas做 話說圓形漸變 這詞也不太對 正式應該叫 Radial Gradient 徑向漸變
 嘛 不用在意那麼多了 這東西曾經在特效裏用過 不過當時寫得比較蛋疼所以重新寫一下
 
 整個工程文件在這裡
  sample.zip
(2.67 KB, 下载次数: 5362) 复制代码from tcaxPy import *
 
def tcaxPy_Init():
 
    # Tips: initialize your global variables here
 
    global _FontSize
 
    global pyFont
 
    _FontSize = GetVal(val_FontSize)
 
    pyFont    = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), GetVal(val_FontSize), GetVal(val_Spacing), GetVal(val_SpaceScale), 0x0000FF, 0, 0)
 
def tcaxPy_Main(_I, _J, _N, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
 
    ASS_BUF = []        # used for saving raw TCS FX data
 
    PIX = TextPix(pyFont, _TXT)                                  # 創建粒子
    InitPosX = _X - int(_A / 2 + 0.5) + PIX[0][0]                # an7 X座標
    InitPosY = _Y - int(_FontSize / 2 + 0.5) + PIX[0][1]         # an7 Y座標
    running = 1                                                  # 無限循環用參數
    while running == 1:
        h = randint(0,PIX[1][1]-1)                               # 隨機取一個點
        w = randint(0,PIX[1][0]-1)
        idx  = 4 * (h * PIX[1][0] + w)                           # PIX元組腳標
        if PIX[2][idx + 3] != 0:                                 # 該點透明度不為0 即該點在文字上時 終止循環 
            running = 0                                          
    B  = InitPosY + h                                            # 該點的X Y 座標
    A = InitPosX + w  
    distance = [int(sqrt(w**2+h**2)),int(sqrt((w-PIX[1][0])**2+h**2)),int(sqrt(w**2+(h-PIX[1][1])**2)),int(sqrt((w-PIX[1][0])**2+(h-PIX[1][1])**2))]             
    dmax = max(distance)+1                                       # 計算點與粒子四個角座標的距離 取最大值 由於小數會捨去所以加1
    C = [ "0000FF", "0080FF","00FFFF","00FF00","FF0000","FFFF00","800080" ]
    Color = DivClr('FFFFFF',C[_J%7],dmax)                       # 拆分顏色
 
    for h in range(PIX[1][1]):                                   # 通常粒子字掃點
        Y  = InitPosY + h                                       
        for w in range(PIX[1][0]):
            X = InitPosX + w                                        
            idx  = 4 * (h * PIX[1][0] + w)
            PixR = PIX[2][idx + 0]
            PixG = PIX[2][idx + 1]
            PixB = PIX[2][idx + 2]
            PixA = PIX[2][idx + 3]
            if PixA != 0:                                   
                d = int(sqrt((X-A)**2+(Y-B)**2))                 # 計算點到中心點的距離
                ass_main(ASS_BUF, SubL(_BT+_SK-5,_ET+_J*5),pos(X,Y)+an(7)+fad(50,150)+bord(0)+alpha(255-PixA)+color1(Color[d]), PixPt())   
    return (ASS_BUF,None)
def tcaxPy_Fin():
 
    # Tips: finalize your global variables here
 
    FinFont(pyFont)
 | 
 |