Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Added depreaction for positive_space_ratio and dash_spacing (#1848)

Jason Villanuevae62425e4f2ed
diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py
index 394cd1b0e..ceddba58c 100644
--- a/manim/mobject/geometry.py
+++ b/manim/mobject/geometry.py
@@ -79,6 +79,7 @@ from ..constants import *
from ..mobject.mobject import Mobject
from ..mobject.types.vectorized_mobject import DashedVMobject, VGroup, VMobject
from ..utils.color import *
+from ..utils.deprecation import deprecated_params
from ..utils.iterables import adjacent_n_tuples, adjacent_pairs
from ..utils.simple_functions import fdiv
from ..utils.space_ops import (
@@ -1114,6 +1115,12 @@ class DashedLine(Line):
:class:`~.DashedVMobject`
"""
+ @deprecated_params(
+ params="positive_space_ratio dash_spacing",
+ since="v0.9.0",
+ message="Use dashed_ratio instead of positive_space_ratio.",
+ redirections=[("positive_space_ratio", "dashed_ratio")],
+ )
def __init__(
self,
*args,
@@ -1121,6 +1128,9 @@ class DashedLine(Line):
dashed_ratio=0.5,
**kwargs,
):
+ self.dash_spacing = kwargs.pop(
+ "dash_spacing", None
+ ) # Unused param, remove with deprecation warning
self.dash_length = dash_length
self.dashed_ratio = dashed_ratio
super().__init__(*args, **kwargs)
diff --git a/manim/mobject/opengl_geometry.py b/manim/mobject/opengl_geometry.py
index 5835859e9..783d97c74 100644
--- a/manim/mobject/opengl_geometry.py
+++ b/manim/mobject/opengl_geometry.py
@@ -9,7 +9,7 @@ from ..mobject.types.opengl_vectorized_mobject import (
OpenGLVMobject,
)
from ..utils.color import *
-from ..utils.deprecation import deprecated
+from ..utils.deprecation import deprecated_params
from ..utils.iterables import adjacent_n_tuples, adjacent_pairs
from ..utils.simple_functions import clip, fdiv
from ..utils.space_ops import (
@@ -525,11 +525,18 @@ class OpenGLLine(OpenGLTipableVMobject):
class OpenGLDashedLine(OpenGLLine):
+ @deprecated_params(
+ params="positive_space_ratio dash_spacing",
+ since="v0.9.0",
+ message="Use dashed_ratio instead of positive_space_ratio.",
+ )
def __init__(
self, *args, dash_length=DEFAULT_DASH_LENGTH, dashed_ratio=0.5, **kwargs
):
+ # Simplify with removal of deprecation warning
+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param
+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratio
self.dash_length = dash_length
- self.dashed_ratio = dashed_ratio
super().__init__(*args, **kwargs)
dashed_ratio = self.dashed_ratio
num_dashes = self.calculate_num_dashes(dashed_ratio)
diff --git a/manim/mobject/types/opengl_vectorized_mobject.py b/manim/mobject/types/opengl_vectorized_mobject.py
index 31ad2bef9..88a4e6de0 100644
--- a/manim/mobject/types/opengl_vectorized_mobject.py
+++ b/manim/mobject/types/opengl_vectorized_mobject.py
@@ -19,6 +19,7 @@ from ...utils.bezier import (
partial_quadratic_bezier_points,
)
from ...utils.color import *
+from ...utils.deprecation import deprecated_params
from ...utils.iterables import listify, make_even, resize_with_interpolation
from ...utils.space_ops import (
angle_between_vectors,
@@ -1227,11 +1228,18 @@ class OpenGLCurvesAsSubmobjects(OpenGLVGroup):
class OpenGLDashedVMobject(OpenGLVMobject):
+ @deprecated_params(
+ params="positive_space_ratio dash_spacing",
+ since="v0.9.0",
+ message="Use dashed_ratio instead of positive_space_ratio.",
+ )
def __init__(
self, vmobject, num_dashes=15, dashed_ratio=0.5, color=WHITE, **kwargs
):
+ # Simplify with removal of deprecation warning
+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param
+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratio
self.num_dashes = num_dashes
- self.dashed_ratio = dashed_ratio
super().__init__(color=color, **kwargs)
r = self.dashed_ratio
n = self.num_dashes
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index 3e83b10cd..69742d198 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -33,6 +33,7 @@ from ...utils.bezier import (
partial_bezier_points,
)
from ...utils.color import BLACK, WHITE, color_to_rgba
+from ...utils.deprecation import deprecated_params
from ...utils.iterables import make_even, stretch_array_to_length, tuplify
from ...utils.simple_functions import clip_in_place
from ...utils.space_ops import rotate_vector, shoelace_direction
@@ -2101,11 +2102,18 @@ class DashedVMobject(VMobject, metaclass=ConvertToOpenGL):
"""
+ @deprecated_params(
+ params="positive_space_ratio dash_spacing",
+ since="v0.9.0",
+ message="Use dashed_ratio instead of positive_space_ratio.",
+ )
def __init__(
self, vmobject, num_dashes=15, dashed_ratio=0.5, color=WHITE, **kwargs
):
+ # Simplify with removal of deprecation warning
+ self.dash_spacing = kwargs.pop("dash_spacing", None) # Unused param
+ self.dashed_ratio = kwargs.pop("positive_space_ratio", None) or dashed_ratio
self.num_dashes = num_dashes
- self.dashed_ratio = dashed_ratio
super().__init__(color=color, **kwargs)
r = self.dashed_ratio
n = self.num_dashes