ManimCommunity / ManimCommunity/manim

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

Open
#4,802 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## 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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in manim/utils/color/core.py at ManimColor.gradient() and compare its intended behavior with the existing module-level color_gradient function. Review the 3b1b/manim implementation as suggested, then add tests for lengths 0 and 1, single-colour input, and alpha values. Done means the public method returns gradients instead of raising NotImplementedError and the edge cases are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.