Skip to content

color: implement ManimColor.gradient() instead of raising NotImplementedError #4802

Description

@Drunsdo

Source

manim/utils/color/core.py, line 964 (as of HEAD ):

@staticmethod
    def gradient(
        colors: list[ManimColor], length: int
    ) -> ManimColor | list[ManimColor]:
        """This method is currently not implemented. Refer to :func:`color_gradient` for
        a working implementation for now.
        """
        # TODO: implement proper gradient, research good implementation for this or look at 3b1b implementation
        raise NotImplementedError

Problem

ManimColor.gradient() is exposed as a public static method with a documented signature and return type, but calling it raises NotImplementedError. Users discovering the method via IDE autocomplete or API docs will be misled. The docstring currently redirects to the module-level color_gradient function as a workaround, but the method itself remains a public API gap.

Suggested approaches

  • Implement the method using the same logic that color_gradient already provides, then have color_gradient delegate to it (or deprecate the function in favour of the method).
  • Reference the 3b1b/manim implementation as a starting point, as the original TODO suggests.
  • Add tests that exercise the method with edge cases (length 0, length 1, single-colour input, colours with alpha).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions