﻿################################################################################
### description:
### expanding particles


from tcaxPy import *


def tcaxPy_Init():
    global _FD                         # frame duration, in millisecond
    global _Fs
    global Font
    _FD = 1000 / GetVal(val_FXFPS)
    _Fs = GetVal(val_FontSize)
    Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)


def tcaxPy_Fin():
    FinFont(Font)


def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
    ASS_BUF  = []        # used for saving ASS FX lines
    TCAS_BUF = []        # used for saving TCAS FX raw data

    ts = _start + _elapk
    te = _start + _elapk + _k
    count = int((te - ts) * 2)
    PIX = TextPix(Font, _txt)
    points = PixPoints(PIX)
    pt_num = len(points)
    dx = _x - int(_a / 2 + 0.5) + PIX[0][0]
    dy = _y - int(_Fs / 2 + 0.5) + PIX[0][1]
    for i in range(count):
        pt = points[randint(0, pt_num - 1)]
        t0 = randint(int(ts), int(te))
        t1 = t0 + 150
        x = dx + pt[0]
        y = dy + pt[1]
        EFT = move(x, y, randint(x - 50, x + 50), randint(y - 35, y + 35)) + fad(0, 300) + alpha1(0) + color1('FFFFFF') + \
              alpha3(0) + color3('003DB8') + bord(2) + blur(2)
        ass_main(ASS_BUF, SubL(t0, t1, 0, Pix_Style), EFT, RandPolygon(2, 2, 6))

    return (ASS_BUF, TCAS_BUF)



