Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ab8b92d
Tex working with artifacts
eulertour Mar 27, 2021
752dce3
Add OpenGLTex
eulertour Mar 28, 2021
e3153f7
Add OpenGLText
eulertour Mar 29, 2021
0c7e98a
Add OpenGLText and related classes
eulertour Mar 29, 2021
c61bf02
Add OpenGLText and related classes
eulertour Mar 29, 2021
1f010ac
Merge remote-tracking branch 'origin/master' into opengl-tex
eulertour Mar 31, 2021
bf3dba2
Undo changes to example code
eulertour Mar 31, 2021
2a861d0
Checks
eulertour Mar 31, 2021
835311c
Fix scaling and family assembly
eulertour Apr 6, 2021
9d920a7
Fix scaling and coloring and merge
eulertour Apr 6, 2021
adb3008
checks
eulertour Apr 6, 2021
df905ad
Merge remote-tracking branch 'origin/master' into opengl-tex
eulertour Apr 6, 2021
b3d2412
Remove OpenGLCairoText
eulertour Apr 6, 2021
358d175
Replace use_opengl_renderer with renderer = opengl
eulertour Apr 8, 2021
742fb12
Merge remote-tracking branch 'origin/master' into opengl-tex
eulertour Apr 8, 2021
e3e913a
Merge branch 'master' into opengl-tex
eulertour Apr 9, 2021
6ee69b0
Merge branch 'master' into opengl-tex
eulertour Apr 9, 2021
c4b2b21
Merge branch 'master' into opengl-tex
eulertour Apr 9, 2021
d374816
Merge commit '9a525a81' into opengl-tex
eulertour Apr 10, 2021
376c83c
Merge commit '5017a494' into opengl-tex
eulertour Apr 10, 2021
f349948
Remove about_point argument
eulertour Apr 10, 2021
69e7758
Use OpenGLRoundedRectangle when necessary
eulertour Apr 10, 2021
2003bd5
Merge branch 'opengl-tex' of github.com:eulertour/manim-1 into opengl…
eulertour Apr 10, 2021
930da70
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2021
1e68fc4
Add OpenGLTex and OpenGLText tests
eulertour Apr 10, 2021
6b92077
Merge branch 'opengl-tex' of github.com:eulertour/manim-1 into opengl…
eulertour Apr 10, 2021
c839226
Remove text test
eulertour Apr 10, 2021
a315d7c
Remove tex test
eulertour Apr 10, 2021
3e3537d
Merge branch 'master' into opengl-tex
kilacoda-old Apr 11, 2021
b322bf2
Add opengl check
eulertour Apr 11, 2021
f11c9a6
Merge branch 'opengl-tex' of github.com:eulertour/manim-1 into opengl…
eulertour Apr 11, 2021
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 @@ -30,6 +30,7 @@

import numpy as np

from .. import config
from ..animation.animation import Animation
from ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME, DEGREES, OUT
from ..mobject.mobject import Group, Mobject
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["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
5 changes: 4 additions & 1 deletion manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ def __deepcopy__(self, clone_from_id):
return result

def __repr__(self):
return str(self.name)
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
95 changes: 94 additions & 1 deletion manim/mobject/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,101 @@ def animate(self):
# Borrowed from https://github.com/ManimCommunity/manim/
return _AnimationBuilder(self)

@property
def width(self):
"""The width of the mobject.

Returns
-------
:class:`float`

Examples
--------
.. manim:: WidthExample

class WidthExample(Scene):
def construct(self):
decimal = DecimalNumber().to_edge(UP)
rect = Rectangle(color=BLUE)
rect_copy = rect.copy().set_stroke(GRAY, opacity=0.5)

decimal.add_updater(lambda d: d.set_value(rect.width))

self.add(rect_copy, rect, decimal)
self.play(rect.animate.set(width=7))
self.wait()

See also
--------
:meth:`length_over_dim`

"""

# Get the length across the X dimension
return self.length_over_dim(0)

# Only these methods should directly affect points
@width.setter
def width(self, value):
self.rescale_to_fit(value, 0, stretch=False)

@property
def height(self):
"""The height of the mobject.

Returns
-------
:class:`float`

Examples
--------
.. manim:: HeightExample

class HeightExample(Scene):
def construct(self):
decimal = DecimalNumber().to_edge(UP)
rect = Rectangle(color=BLUE)
rect_copy = rect.copy().set_stroke(GRAY, opacity=0.5)

decimal.add_updater(lambda d: d.set_value(rect.height))

self.add(rect_copy, rect, decimal)
self.play(rect.animate.set(height=5))
self.wait()

See also
--------
:meth:`length_over_dim`

"""

# Get the length across the Y dimension
return self.length_over_dim(1)

@height.setter
def height(self, value):
self.rescale_to_fit(value, 1, stretch=False)

@property
def depth(self):
"""The depth of the mobject.

Returns
-------
:class:`float`

See also
--------
:meth:`length_over_dim`

"""

# Get the length across the Z dimension
return self.length_over_dim(2)

@depth.setter
def depth(self, value):
self.rescale_to_fit(value, 2, stretch=False)

def resize_points(self, new_length, resize_func=resize_array):
if new_length != len(self.data["points"]):
Expand Down Expand Up @@ -619,7 +713,6 @@ def rotate(
self,
angle,
axis=OUT,
about_point: Union[np.ndarray, List, None] = None,
**kwargs,
):
rot_matrix_T = rotation_matrix_transpose(angle, axis)
Expand Down
42 changes: 42 additions & 0 deletions manim/mobject/svg/opengl_svg_mobject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from ...constants import *
from ..svg.svg_mobject import SVGMobject
from ..types.opengl_vectorized_mobject import OpenGLVMobject
from .opengl_svg_path import OpenGLSVGPathMobject
from .style_utils import cascade_element_style, parse_style


class OpenGLSVGMobject(OpenGLVMobject, SVGMobject):
def __init__(
self,
file_name=None,
should_center=True,
height=2,
width=None,
unpack_groups=True, # if False, creates a hierarchy of VGroups
stroke_width=DEFAULT_STROKE_WIDTH,
fill_opacity=1.0,
should_subdivide_sharp_curves=False,
should_remove_null_curves=False,
**kwargs,
):
self.def_map = {}
self.file_name = file_name or self.file_name
self.ensure_valid_file()
self.should_center = should_center
self.unpack_groups = unpack_groups
self.path_string_config = {
"should_subdivide_sharp_curves": should_subdivide_sharp_curves,
"should_remove_null_curves": should_remove_null_curves,
}
OpenGLVMobject.__init__(
self, stroke_width=stroke_width, fill_opacity=fill_opacity, **kwargs
)
self.move_into_position(width, height)

def init_points(self):
self.generate_points()

def path_string_to_mobject(self, path_string: str, style: dict):
return OpenGLSVGPathMobject(
path_string, **self.path_string_config, **parse_style(style)
)
29 changes: 29 additions & 0 deletions manim/mobject/svg/opengl_svg_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np

from ..types.opengl_vectorized_mobject import OpenGLVMobject
from .svg_path import SVGPathMobject


class OpenGLSVGPathMobject(OpenGLVMobject, SVGPathMobject):
def __init__(
self,
path_string,
should_subdivide_sharp_curves=False,
should_remove_null_curves=False,
**kwargs
):
self.path_string = path_string
OpenGLVMobject.__init__(
self,
long_lines=True,
should_subdivide_sharp_curves=should_subdivide_sharp_curves,
should_remove_null_curves=should_remove_null_curves,
**kwargs
)
self.current_path_start = np.zeros((1, self.dim))

def init_points(self):
self.generate_points()

def start_new_path(self, point):
SVGPathMobject.start_new_path(self, point)
Loading