You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As follows, I am trying to shorten my python scripts' code.
for line in lines:
_lstart = line.start_time
_lend = line.end_time
for syl in line.syls: # Syllable split mode: simplify inline variables (used as global variables)
_si = syl.i
_sstart = syl.start_time
_send = syl.end_time
_sdur = syl.duration
_syln = len(line.syls)+1
_center = syl.center
_middle = syl.middle
_text = syl.text
# Generating lines
if line.styleref.alignment == 8: # line partition judgment (OPJP)
Princess_OPJP(line, line.copy())
The main purpose of this is to shorten code length in def Princess_OPJP(line, l).
def Princess_OPJP(line, l):
if line.style == "Princess_OPJP":
shape = "m 0 0 l 2 0 l 2 50 l 0 50 l 0 0","m 100 0 b 100 -55 55 -100 0 -100 b -55 -100 -100 -55 -100 0 b -100 55 -55 100 0 100 b 55 100 100 55 100 0","m -5 0 l -5 0 l 5 0 l 5 22 l -5 22"
# circle
for j in range(3):
l.layer = 1
# syl
l.start_time = _lstart + _sstart + (-j-1)*100
l.end_time = _lstart + _send + 1000
l.text = "{\\an5\\move(%.f,%.f,%.f,%.f)\\1a%s\\blur%.f\\bord0\\shad0\\fad(200,500)\\p%.f}%s" % (
_center - randint(0,50), _middle - randint(0,50), _center + randint(0,50), _middle + randint(0,50),
Convert.alpha_dec_to_ass(randint(50,150)), randint(1,2), randint(4,6), shape[1])
io.write_line(l)
But doing this like the above, every time I write a script, I have to drag a long list of such codes.
for syl in line.syls: # Syllable split mode: simplify inline variables (used as global variables)
_si = syl.i
_sstart = syl.start_time
_send = syl.end_time
_sdur = syl.duration
_syln = len(line.syls)+1
_center = syl.center
_middle = syl.middle
_text = syl.text
If I want to write _si = syl.i into ass_core.py of pyonfx,
What should I do to ensure that every script I write in the future can read the value of syl.i by writing only one _si?
When I learn Python better, I want to help you update PyonFX with more PRs.
The text was updated successfully, but these errors were encountered:
Seekladoom
changed the title
Try to shorten the code
Try to shorten the code length
Apr 19, 2022
As follows, I am trying to shorten my python scripts' code.
The main purpose of this is to shorten code length in def Princess_OPJP(line, l).
But doing this like the above, every time I write a script, I have to drag a long list of such codes.
If I want to write _si = syl.i into ass_core.py of pyonfx,
What should I do to ensure that every script I write in the future can read the value of syl.i by writing only one _si?
When I learn Python better, I want to help you update PyonFX with more PRs.
The text was updated successfully, but these errors were encountered: