Repository: ManimCommunity/manim
File: manim/utils/color/core.py (Python)

Code before:
        """
        alpha = self._internal_space[3]
        black = self.from_rgb((0.0, 0.0, 0.0))
        return self.interpolate(black, factor).opacity(alpha)

    def lighter(self, factor: float = 0.2) -> Self:
        """Returns a new color that is lighter than the current color, i.e.
        interpolated with white. The opacity is unchanged.

        Parameters
        ----------
        factor : float, optional
            The factor by which the color should be lighter, by default 0.2,
            which results in a slightly lighter color

        Returns
        -------
        ManimColor
            The lighter ManimColor

        See Also
        --------
        :meth:`darker`
        """
        alpha = self._internal_space[3]
        white = self.from_rgb((1.0, 1.0, 1.0))
        return self.interpolate(white, factor).opacity(alpha)

    def contrasting(
        self,
        threshold: float = 0.5,
        light: Self | None = None,
        dark: Self | None = None,
    ) -> Self:
        """Returns one of two colors, light or dark (by default white or black),
        that contrasts with the current color (depending on its luminance).
        This is typically used to set text in a contrasting color that ensures
        it is readable against a background of the current color.

        Parameters
        ----------
        threshold : float, optional
            The luminance threshold that dictates whether the current color is
            considered light or dark (and thus whether to return the dark or
            light color, respectively), by default 0.5
        light : ManimColor, optional
            The light color to return if the current color is considered dark,
            by default pure white
        dark : ManimColor, optional
            The dark color to return if the current color is considered light,
            by default pure black

Review comment (suggestion):
Analogously to above, we should use the available color constant:

```
        from manim.utils.color.manim_colors import WHITE
```

Code after:
        :meth:`lighter`
        """
        from manim.utils.color.manim_colors import BLACK

        alpha = self._internal_space[3]
        black = self._from_internal(BLACK._internal_value)
        return self.interpolate(black, blend).opacity(alpha)

    def lighter(self, blend: float = 0.2) -> Self:
        """Returns a new color that is lighter than the current color, i.e.
        interpolated with white. The opacity is unchanged.

        Parameters
        ----------
        blend : float, optional
            The blend ratio for the interpolation, from 0 (the current color
            unchanged) to 1 (pure white). By default 0.2 which results in a
            slightly lighter color

        Returns
        -------
        ManimColor
            The lighter ManimColor

        See Also
        --------
        :meth:`darker`
        """
        from manim.utils.color.manim_colors import WHITE

        alpha = self._internal_space[3]
        white = self._from_internal(WHITE._internal_value)
        return self.interpolate(white, blend).opacity(alpha)

    def contrasting(
        self,
        threshold: float = 0.5,
        light: Self | None = None,
        dark: Self | None = None,
    ) -> Self:
        """Returns one of two colors, light or dark (by default white or black),
        that contrasts with the current color (depending on its luminance).
        This is typically used to set text in a contrasting color that ensures
        it is readable against a background of the current color.

        Parameters
        ----------
        threshold : float, optional
            The luminance threshold that dictates whether the current color is
            considered light or dark (and thus whether to return the dark or
            light color, respectively), by default 0.5