Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion manim/animation/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from ..mobject.opengl_mobject import OpenGLMobject
from ..utils.paths import path_along_arc, straight_path
from ..utils.rate_functions import smooth, squish_rate_func
from .. import config

if typing.TYPE_CHECKING:
from ..scene.scene import Scene
Expand Down Expand Up @@ -80,7 +81,10 @@ def begin(self) -> None:
self.target_copy = self.target_mobject.copy()
# Note, this potentially changes the structure
# of both mobject and target_mobject
self.mobject.align_data(self.target_copy)
if config["use_opengl_renderer"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if config["use_opengl_renderer"]:
if config.renderer == "opengl":

self.mobject.align_data_and_family(self.target_copy)
else:
self.mobject.align_data(self.target_copy)
super().begin()

def create_target(self) -> typing.Union[Mobject, None]:
Expand Down
16 changes: 8 additions & 8 deletions manim/mobject/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,14 +655,14 @@ def __init__(self, label, radius=None, **kwargs) -> None:
class Ellipse(Circle):
"""A circular shape; oval, circle.

Parameters
----------
width : :class:`float`, optional
The horizontal width of the ellipse.
height : :class:`float`, optional
The vertical height of the ellipse.
kwargs : Any
Additional arguments to be passed to :class:`Circle`
Parameters
----------
width : :class:`float`, optional
The horizontal width of the ellipse.
height : :class:`float`, optional
The vertical height of the ellipse.
kwargs : Any
Additional arguments to be passed to :class:`Circle`

Examples
--------
Expand Down
5 changes: 4 additions & 1 deletion manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def __deepcopy__(self, clone_from_id):
return result

def __repr__(self):
return str(self.name)
if config["use_opengl_renderer"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if config["use_opengl_renderer"]:
if config.renderer == "opengl":

return super().__repr__()
else:
return str(self.name)

def reset_points(self):
"""Sets :attr:`points` to be an empty array."""
Expand Down
51 changes: 51 additions & 0 deletions manim/mobject/opengl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,57 @@ def __init__(self, radius=DEFAULT_SMALL_DOT_RADIUS, **kwargs):
super().__init__(radius=radius, **kwargs)


class OpenGLLabeledDot(OpenGLDot):
"""A :class:`Dot` containing a label in its center.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""A :class:`Dot` containing a label in its center.
"""A :class:`~.OpenGLDot` containing a label in its center.


Parameters
----------
label : Union[:class:`str`, :class:`~.SingleStringMathTex`, :class:`~.Text`, :class:`~.Tex`]
The label of the :class:`Dot`. This is rendered as :class:`~.MathTex`
by default (i.e., when passing a :class:`str`), but other classes
representing rendered strings like :class:`~.Text` or :class:`~.Tex`
can be passed as well.

radius : :class:`float`
The radius of the :class:`Dot`. If ``None`` (the default), the radius
is calculated based on the size of the ``label``.

Examples
--------

.. manim:: SeveralLabeledDots
:save_last_frame:

class SeveralLabeledDots(Scene):
def construct(self):
sq = Square(fill_color=RED, fill_opacity=1)
self.add(sq)
dot1 = LabeledDot(Tex("42", color=RED))
dot2 = LabeledDot(MathTex("a", color=GREEN))
dot3 = LabeledDot(Text("ii", color=BLUE))
dot4 = LabeledDot("3")
dot1.next_to(sq, UL)
dot2.next_to(sq, UR)
dot3.next_to(sq, DL)
dot4.next_to(sq, DR)
self.add(dot1, dot2, dot3, dot4)
"""

def __init__(self, label, radius=None, **kwargs) -> None:
if isinstance(label, str):
from ..mobject.svg.opengl_tex_mobject import OpenGLMathTex

rendered_label = OpenGLMathTex(label, color=BLACK)
else:
rendered_label = label

if radius is None:
radius = 0.1 + max(rendered_label.width, rendered_label.height) / 2
OpenGLDot.__init__(self, radius=radius, **kwargs)
rendered_label.move_to(self.get_center())
self.add(rendered_label)


class OpenGLEllipse(OpenGLCircle):
def __init__(self, width=2, height=1, **kwargs):
super().__init__(**kwargs)
Expand Down
Loading