Skip to content

Commit

Permalink
Merge branch 'main' into run-time-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan050 authored Oct 28, 2024
2 parents 019f31c + 20f44b4 commit 4b859a4
Show file tree
Hide file tree
Showing 15 changed files with 457 additions and 264 deletions.
139 changes: 81 additions & 58 deletions manim/mobject/geometry/arc.py

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions manim/mobject/geometry/boolean_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from manim.mobject.types.vectorized_mobject import VMobject

if TYPE_CHECKING:
from manim.typing import Point2D_Array, Point3D_Array
from typing import Any

from manim.typing import InternalPoint3D_Array, Point2D_Array

from ...constants import RendererType

Expand All @@ -30,7 +32,7 @@ def _convert_2d_to_3d_array(
self,
points: Point2D_Array,
z_dim: float = 0.0,
) -> Point3D_Array:
) -> InternalPoint3D_Array:
"""Converts an iterable with coordinates in 2D to 3D by adding
:attr:`z_dim` as the Z coordinate.
Expand All @@ -51,13 +53,14 @@ def _convert_2d_to_3d_array(
>>> a = _BooleanOps()
>>> p = [(1, 2), (3, 4)]
>>> a._convert_2d_to_3d_array(p)
[array([1., 2., 0.]), array([3., 4., 0.])]
array([[1., 2., 0.],
[3., 4., 0.]])
"""
points = list(points)
for i, point in enumerate(points):
list_of_points = list(points)
for i, point in enumerate(list_of_points):
if len(point) == 2:
points[i] = np.array(list(point) + [z_dim])
return points
list_of_points[i] = np.array(list(point) + [z_dim])
return np.asarray(list_of_points)

def _convert_vmobject_to_skia_path(self, vmobject: VMobject) -> SkiaPath:
"""Converts a :class:`~.VMobject` to SkiaPath. This method only works for
Expand Down Expand Up @@ -95,7 +98,7 @@ def _convert_vmobject_to_skia_path(self, vmobject: VMobject) -> SkiaPath:
if vmobject.consider_points_equals(subpath[0], subpath[-1]):
path.close()
elif config.renderer == RendererType.CAIRO:
subpaths = vmobject.gen_subpaths_from_points_2d(points)
subpaths = vmobject.gen_subpaths_from_points_2d(points) # type: ignore[assignment]
for subpath in subpaths:
quads = vmobject.gen_cubic_bezier_tuples_from_points(subpath)
start = subpath[0]
Expand Down Expand Up @@ -177,7 +180,7 @@ def construct(self):
"""

def __init__(self, *vmobjects: VMobject, **kwargs) -> None:
def __init__(self, *vmobjects: VMobject, **kwargs: Any) -> None:
if len(vmobjects) < 2:
raise ValueError("At least 2 mobjects needed for Union.")
super().__init__(**kwargs)
Expand Down Expand Up @@ -216,7 +219,7 @@ def construct(self):
"""

def __init__(self, subject: VMobject, clip: VMobject, **kwargs) -> None:
def __init__(self, subject: VMobject, clip: VMobject, **kwargs: Any) -> None:
super().__init__(**kwargs)
outpen = SkiaPath()
difference(
Expand Down Expand Up @@ -258,7 +261,7 @@ def construct(self):
"""

def __init__(self, *vmobjects: VMobject, **kwargs) -> None:
def __init__(self, *vmobjects: VMobject, **kwargs: Any) -> None:
if len(vmobjects) < 2:
raise ValueError("At least 2 mobjects needed for Intersection.")

Expand Down Expand Up @@ -311,7 +314,7 @@ def construct(self):
"""

def __init__(self, subject: VMobject, clip: VMobject, **kwargs) -> None:
def __init__(self, subject: VMobject, clip: VMobject, **kwargs: Any) -> None:
super().__init__(**kwargs)
outpen = SkiaPath()
xor(
Expand Down
19 changes: 13 additions & 6 deletions manim/mobject/geometry/labeled.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

__all__ = ["LabeledLine", "LabeledArrow"]

from typing import TYPE_CHECKING

from manim.constants import *
from manim.mobject.geometry.line import Arrow, Line
from manim.mobject.geometry.shape_matchers import (
Expand All @@ -14,6 +16,9 @@
from manim.mobject.text.text_mobject import Text
from manim.utils.color import WHITE, ManimColor, ParsableManimColor

if TYPE_CHECKING:
from typing import Any


class LabeledLine(Line):
"""Constructs a line containing a label box somewhere along its length.
Expand Down Expand Up @@ -67,17 +72,19 @@ def __init__(
font_size: float = DEFAULT_FONT_SIZE,
label_color: ParsableManimColor = WHITE,
label_frame: bool = True,
frame_fill_color: ParsableManimColor = None,
frame_fill_color: ParsableManimColor | None = None,
frame_fill_opacity: float = 1,
*args,
**kwargs,
*args: Any,
**kwargs: Any,
) -> None:
label_color = ManimColor(label_color)
frame_fill_color = ManimColor(frame_fill_color)
if isinstance(label, str):
from manim import MathTex

rendered_label = MathTex(label, color=label_color, font_size=font_size)
rendered_label: Tex | MathTex | Text = MathTex(
label, color=label_color, font_size=font_size
)
else:
rendered_label = label

Expand Down Expand Up @@ -149,7 +156,7 @@ def construct(self):

def __init__(
self,
*args,
**kwargs,
*args: Any,
**kwargs: Any,
) -> None:
super().__init__(*args, **kwargs)
Loading

0 comments on commit 4b859a4

Please sign in to comment.