Skip to content

Commit

Permalink
Update example to use the new version of the FrameUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
moi15moi committed Nov 7, 2023
1 parent d7179f2 commit cd8dae9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion examples/2 - Beginner/2 - Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
As exercise, you can try to transform it into an horizontal one :)
"""

from fractions import Fraction
from pyonfx import *
import random

io = Ass("in.ass")
meta, styles, lines = io.get_data()

# Let's load the timestamps
timestamps_list = Timestamps.from_fps(Fraction(24000, 1001))


def romaji(line, l):
for syl in Utils.all_non_empty(line.syls):
Expand All @@ -44,7 +48,9 @@ def romaji(line, l):
# Main Effect
# Let's create a FrameUtility object and set up a radius for the random positions
FU = FrameUtility(
line.start_time + syl.start_time, line.start_time + syl.end_time
line.start_time + syl.start_time,
line.start_time + syl.end_time,
timestamps_list,
)
radius = 2

Expand Down
12 changes: 10 additions & 2 deletions examples/2 - Beginner/3 - Variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
It could look like much code for such a simple effect, but it's needed and an easy method with much potential for extensions.
"""

from fractions import Fraction
from pyonfx import *
import random
import math
Expand All @@ -27,6 +28,9 @@
star = Shape.star(5, 4, 10)
CU = ColorUtility(lines)

# Let's load the timestamps
timestamps_list = Timestamps.from_fps(Fraction(24000, 1001))


def romaji(line, l):
# Setting up a delay, we will use it as duration time of the leadin and leadout effects
Expand Down Expand Up @@ -107,7 +111,9 @@ def romaji(line, l):
# Jump-in to the first syl
jump_height = 18
if syl.i == 0:
FU = FrameUtility(line.start_time - line.leadin / 2, line.start_time)
FU = FrameUtility(
line.start_time - line.leadin / 2, line.start_time, timestamps_list
)
for s, e, i, n in FU:
l.start_time = s
l.end_time = e
Expand All @@ -133,7 +139,9 @@ def romaji(line, l):
else syl.width
)
FU = FrameUtility(
line.start_time + syl.start_time, line.start_time + syl.end_time
line.start_time + syl.start_time,
line.start_time + syl.end_time,
timestamps_list,
)
for s, e, i, n in FU:
l.start_time = s
Expand Down
8 changes: 7 additions & 1 deletion examples/3 - Advanced/1 - WIP.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from fractions import Fraction
from pyonfx import *
import random

io = Ass("in.ass")
meta, styles, lines = io.get_data()

# Let's load the timestamps
timestamps_list = Timestamps.from_fps(Fraction(24000, 1001))

circle = Shape.ellipse(20, 20)


Expand All @@ -29,7 +33,9 @@ def romaji(line, l):
l.layer = 1

FU = FrameUtility(
line.start_time + syl.start_time, line.start_time + syl.end_time
line.start_time + syl.start_time,
line.start_time + syl.end_time,
timestamps_list,
)
rand = random.uniform(-10, 10)

Expand Down

0 comments on commit cd8dae9

Please sign in to comment.