mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Fix creation or animation of a zero-length DashedLine (#4606)
* fixing #4591 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
7c1c9258d0
commit
e34e707858
2 changed files with 19 additions and 2 deletions
|
|
@ -241,7 +241,8 @@ class TipableVMobject(VMobject, metaclass=ConvertToOpenGL):
|
|||
if self.has_start_tip():
|
||||
result.add(self.start_tip)
|
||||
self.remove(self.start_tip)
|
||||
self.put_start_and_end_on(start, end)
|
||||
if result.submobjects:
|
||||
self.put_start_and_end_on(start, end)
|
||||
return result
|
||||
|
||||
def get_tips(self) -> VGroup:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from manim import ORIGIN, UR, Arrow, DashedVMobject, VGroup
|
||||
from manim import ORIGIN, UR, Arrow, DashedLine, DashedVMobject, VGroup
|
||||
from manim.mobject.geometry.tips import ArrowTip, StealthTip
|
||||
|
||||
|
||||
|
|
@ -41,3 +41,19 @@ def test_dashed_arrow_with_start_tip_has_two_tips():
|
|||
tips = _collect_tips(dashed)
|
||||
|
||||
assert len(tips) == 2
|
||||
|
||||
|
||||
def test_zero_length_dashed_line_submobjects_have_2d_points():
|
||||
"""Submobjects of a zero-length DashedLine must have 2-D point arrays."""
|
||||
line = DashedLine(ORIGIN, ORIGIN)
|
||||
for sub in line.submobjects:
|
||||
assert sub.points.ndim == 2, (
|
||||
f"Expected 2-D points array, got shape {sub.points.shape}"
|
||||
)
|
||||
|
||||
|
||||
def test_become_nonzero_to_zero_dashed_line_does_not_crash():
|
||||
"""become() from a normal DashedLine to a zero-length one should not crash."""
|
||||
normal = DashedLine(ORIGIN, 2 * UR)
|
||||
zero = DashedLine(ORIGIN, ORIGIN)
|
||||
normal.become(zero)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue