From d3ac66ebb19cea0d0b411e232e05603dbc98829d Mon Sep 17 00:00:00 2001 From: Eddie Ruiz Date: Sat, 22 Jun 2024 16:19:06 -0400 Subject: [PATCH 1/3] fix: Issue with ``TipableVMobject`` class where getting the start and end positions of an object would include the length of an added tip, instead of the expected length without the tip. --- manim/mobject/geometry/arc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/mobject/geometry/arc.py b/manim/mobject/geometry/arc.py index dd532b07b6..eb6a9d2e37 100644 --- a/manim/mobject/geometry/arc.py +++ b/manim/mobject/geometry/arc.py @@ -264,13 +264,13 @@ def get_last_handle(self) -> Point3D: def get_end(self) -> Point3D: if self.has_tip(): - return self.tip.get_start() + return self.tip.base else: return super().get_end() def get_start(self) -> Point3D: if self.has_start_tip(): - return self.start_tip.get_start() + return self.start_tip.base else: return super().get_start() From 6585104a9f82f45869f539d92581e9a6df1572cb Mon Sep 17 00:00:00 2001 From: Eddie Ruiz Date: Sat, 22 Jun 2024 16:21:48 -0400 Subject: [PATCH 2/3] fix: Issue where the final tick of a ``NumberLine`` would sometimes not appear. Also, the size of a tip when added after creation with default parameters did not match the size when added during creation. --- manim/mobject/graphing/number_line.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/manim/mobject/graphing/number_line.py b/manim/mobject/graphing/number_line.py index 26df7df044..6f5afa16bd 100644 --- a/manim/mobject/graphing/number_line.py +++ b/manim/mobject/graphing/number_line.py @@ -9,7 +9,7 @@ from collections.abc import Iterable, Sequence -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING, Callable, Self if TYPE_CHECKING: from manim.mobject.geometry.tips import ArrowTip @@ -236,7 +236,6 @@ def __init__( tip_width=self.tip_width, tip_shape=tip_shape, ) - self.tip.set_stroke(self.stroke_color, self.stroke_width) if self.include_ticks: self.add_ticks() @@ -275,6 +274,26 @@ def rotate_about_number( ): return self.rotate(angle, axis, about_point=self.n2p(number), **kwargs) + def add_tip( + self, + tip: ArrowTip | None = None, + tip_shape: type[ArrowTip] | None = None, + tip_length: float | None = None, + tip_width: float | None = None, + at_start: bool = False, + ) -> Self: + if tip_length is None: + tip_length = self.tip_height + + if tip_width is None: + tip_width = self.tip_width + + super().add_tip(tip, tip_shape, tip_length, tip_width, at_start) + + self.tip.set_stroke(self.stroke_color, self.stroke_width) + + return self + def add_ticks(self): """Adds ticks to the number line. Ticks can be accessed after creation via ``self.ticks``.""" @@ -325,8 +344,7 @@ def get_tick_range(self) -> np.ndarray: A numpy array of floats represnting values along the number line. """ x_min, x_max, x_step = self.x_range - if not self.include_tip: - x_max += 1e-6 + x_max += 1e-6 # Handle cases where min and max are both positive or both negative if x_min < x_max < 0 or x_max > x_min > 0: From e7b86bab834cb8d5f5651fa5f5314255a4521ed6 Mon Sep 17 00:00:00 2001 From: Eddie Ruiz Date: Sat, 22 Jun 2024 16:43:53 -0400 Subject: [PATCH 3/3] Issue with importing the wrong ``Self``. --- manim/mobject/graphing/number_line.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manim/mobject/graphing/number_line.py b/manim/mobject/graphing/number_line.py index 6f5afa16bd..98715c3f31 100644 --- a/manim/mobject/graphing/number_line.py +++ b/manim/mobject/graphing/number_line.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing_extensions import Self + from manim.mobject.mobject import Mobject from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject @@ -9,7 +11,7 @@ from collections.abc import Iterable, Sequence -from typing import TYPE_CHECKING, Callable, Self +from typing import TYPE_CHECKING, Callable if TYPE_CHECKING: from manim.mobject.geometry.tips import ArrowTip