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

Code before:
    >>> rnd_custom = RandomColorGenerator(1, sample_colors=custom_palette)
    >>> rnd_custom.next() in custom_palette
    True
    >>> rnd_custom.next() in custom_palette
    True

    Without a seed and custom palette (non-deterministic):
    >>> rnd_nodet = RandomColorGenerator(sample_colors=[RED])
    >>> rnd_nodet.next()
    ManimColor('#FC6255')
    """

    def __init__(
        self,
        seed: int | None = None,
        sample_colors: list[ManimColor] | None = None,
    ) -> None:
        self.choice = random.choice if seed is None else random.Random(seed).choice

        from manim.utils.color.manim_colors import _all_manim_colors

        self.colors = _all_manim_colors if sample_colors is None else sample_colors

    def next(self) -> ManimColor:
        """
        Returns the next color from the configured color list.

        Returns
        -------
        ManimColor
            A randomly selected color from the specified color list.

        Examples
        --------
        >>> from manim import RandomColorGenerator, RED
        >>> rnd = RandomColorGenerator(sample_colors=[RED])
        >>> rnd.next()
        ManimColor('#FC6255')
        """
        return self.choice(self.colors)


def get_shaded_rgb(
    rgb: RGB_Array_Float,
    point: Point3D,
    unit_normal_vect: Vector3D,
    light_source: Point3D,
) -> RGB_Array_Float:
    """Add light or shadow to the ``rgb`` color of some surface which is located at a
    given ``point`` in space and facing in the direction of ``unit_normal_vect``,
    depending on whether the surface is facing a ``light_source`` or away from it.

Review comment (suggestion):
```suggestion
        """Return the next color from the configured color list.
```

Code after:
    Using a custom color list::

        >>> custom_palette = [RED, GREEN, BLUE]
        >>> rnd_custom = RandomColorGenerator(1, sample_colors=custom_palette)
        >>> rnd_custom.next() in custom_palette
        True
        >>> rnd_custom.next() in custom_palette
        True

    Without a seed and custom palette (non-deterministic)::

        >>> rnd_nodet = RandomColorGenerator(sample_colors=[RED])
        >>> rnd_nodet.next()
        ManimColor('#FC6255')
    """

    def __init__(
        self,
        seed: int | None = None,
        sample_colors: list[ManimColor] | None = None,
    ) -> None:
        self.choice = random.choice if seed is None else random.Random(seed).choice

        from manim.utils.color.manim_colors import _all_manim_colors

        self.colors = _all_manim_colors if sample_colors is None else sample_colors

    def next(self) -> ManimColor:
        """Returns the next color from the configured color list.

        Returns
        -------
        ManimColor
            A randomly selected color from the specified color list.

        Examples
        --------
        Usage::

            >>> from manim import RandomColorGenerator, RED
            >>> rnd = RandomColorGenerator(sample_colors=[RED])
            >>> rnd.next()
            ManimColor('#FC6255')
        """
        return self.choice(self.colors)

    @classmethod
    def _random_color(cls) -> ManimColor:
        """Internal method to generate a random color using the singleton instance of
        `RandomColorGenerator`.
        It will be used by proxy method `random_color` publicly available