Skip to content

Commit 3c6ea0e

Browse files
nubDotDevchopan050
andauthored
Allow passing a buff to LabeledDot (#4403)
* Give LabeledDot a buffer and improve radius calculation * fix norm calculation * documentation --------- Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>
1 parent 00d0b29 commit 3c6ea0e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

manim/mobject/geometry/arc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,9 @@ class LabeledDot(Dot):
825825
representing rendered strings like :class:`~.Text` or :class:`~.Tex`
826826
can be passed as well.
827827
radius
828-
The radius of the :class:`Dot`. If ``None`` (the default), the radius
829-
is calculated based on the size of the ``label``.
828+
The radius of the :class:`Dot`. If provided, the ``buff`` is ignored.
829+
If ``None`` (the default), the radius is calculated based on the size
830+
of the ``label`` and the ``buff``.
830831
831832
Examples
832833
--------
@@ -852,6 +853,7 @@ def __init__(
852853
self,
853854
label: str | SingleStringMathTex | Text | Tex,
854855
radius: float | None = None,
856+
buff: float = SMALL_BUFF,
855857
**kwargs: Any,
856858
) -> None:
857859
if isinstance(label, str):
@@ -862,7 +864,9 @@ def __init__(
862864
rendered_label = label
863865

864866
if radius is None:
865-
radius = 0.1 + max(rendered_label.width, rendered_label.height) / 2
867+
radius = buff + float(
868+
np.linalg.norm([rendered_label.width, rendered_label.height]) / 2
869+
)
866870
super().__init__(radius=radius, **kwargs)
867871
rendered_label.move_to(self.get_center())
868872
self.add(rendered_label)

0 commit comments

Comments
 (0)