Skip to content

Commit

Permalink
fix: line positioning error when there is no progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jkjkil4 committed Jun 2, 2024
1 parent 15fa943 commit 0133931
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions janim/anims/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def build(self, *, quiet=False) -> TimelineAnim:
self.construct()

if self.current_time == 0:
self.forward(DEFAULT_DURATION) # 使得没有任何前进时,产生一点时间,避免除零以及其它问题
self.forward(DEFAULT_DURATION, _record_lineno=False) # 使得没有任何前进时,产生一点时间,避免除零以及其它问题
if not quiet: # pragma: no cover
log.info(f'"{self.__class__.__name__}" 构建后没有产生时长,自动产生了 {DEFAULT_DURATION}s 的时长')
self.cleanup_display()
Expand All @@ -228,7 +228,7 @@ def schedule(self, at: float, func: Callable, *args, **kwargs) -> None:

# region progress

def forward(self, dt: float = 1, *, _detect_changes=True) -> None:
def forward(self, dt: float = 1, *, _detect_changes=True, _record_lineno=True) -> None:
'''
向前推进 ``dt`` 秒
'''
Expand All @@ -247,12 +247,13 @@ def forward(self, dt: float = 1, *, _detect_changes=True) -> None:

self.current_time = to_time

self.times_of_code.append(
Timeline.TimeOfCode(
self.current_time,
self.get_construct_lineno() or -1
if _record_lineno:
self.times_of_code.append(
Timeline.TimeOfCode(
self.current_time,
self.get_construct_lineno() or -1
)
)
)

def forward_to(self, t: float, *, _detect_changes=True) -> None:
'''
Expand Down

0 comments on commit 0133931

Please sign in to comment.