manim/tests/test_graphical_units/test_mobjects.py
Alexander Vázquez 388504307a
Implemented :class:.LineJointTypes for both Cairo and OpenGL renderer (#3016)
* LineJoins added

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added joint type enum, refactored proposed implementation

* added test for joint types

* added documentation

* let LineJointType.AUTO be rendered like before

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update added example in basic.py to reflect changed implementation

* fix RTD build

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* moved rendered example in documentation

* [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>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
2022-11-13 16:14:55 -07:00

55 lines
1.5 KiB
Python

from __future__ import annotations
from manim import *
from manim.utils.testing.frames_comparison import frames_comparison
__module_test__ = "mobjects"
@frames_comparison(base_scene=ThreeDScene)
def test_PointCloudDot(scene):
p = PointCloudDot()
scene.add(p)
@frames_comparison
def test_become(scene):
s = Rectangle(width=2, height=1, color=RED).shift(UP)
d1, d2, d3 = (Dot() for _ in range(3))
s1 = s.copy().become(d1, match_width=True).set_opacity(0.25).set_color(BLUE)
s2 = (
s.copy()
.become(d2, match_height=True, match_center=True)
.set_opacity(0.25)
.set_color(GREEN)
)
s3 = s.copy().become(d3, stretch=True).set_opacity(0.25).set_color(YELLOW)
scene.add(s, d1, d2, d3, s1, s2, s3)
@frames_comparison
def test_match_style(scene):
square = Square(fill_color=[RED, GREEN], fill_opacity=1)
circle = Circle()
VGroup(square, circle).arrange()
circle.match_style(square)
scene.add(square, circle)
@frames_comparison
def test_vmobject_joint_types(scene):
angled_line = VMobject(stroke_width=20, color=GREEN).set_points_as_corners(
[
np.array([-2, 0, 0]),
np.array([0, 0, 0]),
np.array([-2, 1, 0]),
]
)
lines = VGroup(*[angled_line.copy() for _ in range(len(LineJointType))])
for line, joint_type in zip(lines, LineJointType):
line.joint_type = joint_type
lines.arrange(RIGHT, buff=1)
scene.add(lines)