Skip to content

Commit

Permalink
Revert "Merge :class:~.OpenGLMobject and :class:~.Mobject (ManimC…
Browse files Browse the repository at this point in the history
…ommunity#1167)"

This reverts commit e18db42.
  • Loading branch information
markromanmiller authored Mar 29, 2021
1 parent d8d9a01 commit 39d432e
Showing 10 changed files with 1,802 additions and 822 deletions.
40 changes: 6 additions & 34 deletions example_scenes/opengl.py
Original file line number Diff line number Diff line change
@@ -54,42 +54,13 @@ def construct(self):
# always(circle.move_to, self.mouse_point)


class SquareToCircle(Scene):
def construct(self):
square = OpenGLSquare()
circle = OpenGLCircle()

self.add(square)
self.wait()

self.play(Transform(square, circle))
self.wait()


class UpdaterTest(Scene):
def construct(self):
squares = OpenGLVGroup()
for _ in range(9):
squares.add(OpenGLSquare(1, stroke_opacity=0).set_fill(WHITE, 0.5))
squares.arrange_in_grid(3, 3, buff=0)

def line():
return OpenGLLine(ORIGIN, squares.get_corner(UL))

self.add(always_redraw(line))
self.play(squares.animate.to_edge(UP))
self.play(squares.animate.to_edge(DR))
self.play(squares.animate.shift(LEFT * 10))
self.wait()


class SurfaceExample(Scene):
def construct(self):
surface_text = Tex("For 3d scenes, try using surfaces")
surface_text.fix_in_frame()
surface_text.to_edge(UP)
self.add(surface_text)
self.wait(0.1)
# surface_text = Text("For 3d scenes, try using surfaces")
# surface_text.fix_in_frame()
# surface_text.to_edge(UP)
# self.add(surface_text)
# self.wait(0.1)

torus1 = OpenGLTorus(r1=1, r2=1)
torus2 = OpenGLTorus(r1=3, r2=1)
@@ -152,6 +123,7 @@ def construct(self):
# light_text = Text("You can move around the light source")
# light_text.move_to(surface_text)
# light_text.fix_in_frame()

# self.play(FadeTransform(surface_text, light_text))
light = self.camera.light_source
self.add(light)
8 changes: 7 additions & 1 deletion manim/animation/animation.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
from ..mobject import opengl_mobject
from ..mobject.mobject import Mobject
from ..utils.rate_functions import smooth
from ..mobject.opengl_mobject import OpenGLMobject

DEFAULT_ANIMATION_RUN_TIME: float = 1.0
DEFAULT_ANIMATION_LAG_RATIO: float = 0.0
@@ -63,7 +64,9 @@ def __init__(
def _typecheck_input(self, mobject: Mobject) -> None:
if mobject is None:
logger.debug("creating dummy animation")
elif not isinstance(mobject, Mobject):
elif not isinstance(mobject, Mobject) and not isinstance(
mobject, OpenGLMobject
):
raise TypeError("Animation only works on Mobjects")

def __str__(self) -> str:
@@ -229,6 +232,9 @@ def prepare_animation(
if isinstance(anim, mobject._AnimationBuilder):
return anim.build()

if isinstance(anim, opengl_mobject._AnimationBuilder):
return anim.build()

if isinstance(anim, Animation):
return anim

3 changes: 2 additions & 1 deletion manim/animation/transform.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
from ..animation.animation import Animation
from ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME, DEGREES, OUT
from ..mobject.mobject import Group, Mobject
from ..mobject.opengl_mobject import OpenGLMobject
from ..utils.paths import path_along_arc, straight_path
from ..utils.rate_functions import smooth, squish_rate_func

@@ -217,7 +218,7 @@ def check_validity_of_input(self, method: types.MethodType) -> None:
"Whoops, looks like you accidentally invoked "
"the method you want to animate"
)
assert isinstance(method.__self__, Mobject)
assert isinstance(method.__self__, (Mobject, OpenGLMobject))

def create_target(self) -> Mobject:
method = self.method
Loading

0 comments on commit 39d432e

Please sign in to comment.