Repository: ManimCommunity/manim
File: manim/mobject/geometry/labeled.py (Python)

Code before:
r"""Mobjects that inherit from lines and contain a label along the length."""

from __future__ import annotations

__all__ = ["LabeledLine", "LabeledArrow"]

from manim.constants import *
from manim.mobject.geometry.line import Arrow, Line
from manim.mobject.geometry.shape_matchers import (
    BackgroundRectangle,
    SurroundingRectangle,
)
from manim.mobject.text.tex_mobject import MathTex, Tex
from manim.mobject.text.text_mobject import Text
from manim.utils.color import *
from manim.utils.color import Color


class LabeledLine(Line):
    """Constructs a line containing a label box somewhere along its length.

    Parameters
    ----------
    label : str | Tex | MathTex | Text
        Label that will be displayed on the line.
    label_position : float | optional
        A ratio in the range [0-1] to indicate the position of the label with respect to the length of the line. Default value is 0.5.
    font_size : float | optional
        Control font size for the label. This parameter is only used when `label` is of type `str`.
    label_color: numpy.ndarray | optional
        The color of the label's text. This parameter is only used when `label` is of type `str`.
    label_frame : Bool | optional
        Add a `SurroundingRectangle` frame to the label box.
    frame_fill_color : numpy.ndarray | optional
        Background color to fill the label box. If no value is provided, the background color of the canvas will be used.
    frame_fill_opacity : float | optional
        Determine the opacity of the label box by passing a value in the range [0-1], where 0 indicates complete transparency and 1 means full opacity.

    .. seealso::
        :class:`LabeledArrow`

Review comment (suggestion):
This is only imported for the constant WHITE, which could be removed since a default color of None makes it WHITE anyways.
```suggestion
```

Code after:
r"""Mobjects that inherit from lines and contain a label along the length."""

from __future__ import annotations

__all__ = ["LabeledLine", "LabeledArrow"]

from manim.constants import *
from manim.mobject.geometry.line import Arrow, Line
from manim.mobject.geometry.shape_matchers import (
    BackgroundRectangle,
    SurroundingRectangle,
)
from manim.mobject.text.tex_mobject import MathTex, Tex
from manim.mobject.text.text_mobject import Text
from manim.utils.color import WHITE, Color


class LabeledLine(Line):
    """Constructs a line containing a label box somewhere along its length.

    Parameters
    ----------
    label : str | Tex | MathTex | Text
        Label that will be displayed on the line.
    label_position : float | optional
        A ratio in the range [0-1] to indicate the position of the label with respect to the length of the line. Default value is 0.5.
    font_size : float | optional
        Control font size for the label. This parameter is only used when `label` is of type `str`.
    label_color: numpy.ndarray | optional
        The color of the label's text. This parameter is only used when `label` is of type `str`.
    label_frame : Bool | optional
        Add a `SurroundingRectangle` frame to the label box.
    frame_fill_color : numpy.ndarray | optional
        Background color to fill the label box. If no value is provided, the background color of the canvas will be used.
    frame_fill_opacity : float | optional
        Determine the opacity of the label box by passing a value in the range [0-1], where 0 indicates complete transparency and 1 means full opacity.

    .. seealso::
        :class:`LabeledArrow`