Skip to content

Implement ManimColor.gradient() by delegating to color_gradient() - #4997

Open
webzuweb wants to merge 2 commits into
ManimCommunity:mainfrom
webzuweb:feat/implement-manimcolor-gradient
Open

webzuweb wants to merge 2 commits into
ManimCommunity:mainfrom
webzuweb:feat/implement-manimcolor-gradient

Conversation

@webzuweb

@webzuweb webzuweb commented Sep 7, 2026

Copy link
Copy Markdown

Summary

ManimColor.gradient() is a public static method with a documented signature and return type, but it raises NotImplementedError. Users discovering it via autocomplete or API docs get misled (the docstring redirected to the module-level color_gradient).

Change

  • Implement ManimColor.gradient(colors, length) by delegating to the existing color_gradient() logic (single source of truth).
  • Correct the return annotation to list[ManimColor] (the old ManimColor | list[ManimColor] was inaccurate — it always returns a list).
  • Rewrite the docstring to match the module function.

Tests

Added in tests/module/utils/test_color_helpers.py:

  • zero length returns empty list
  • empty reference colors raises ValueError
  • single reference color is repeated
  • endpoints interpolated correctly
  • parity with color_gradient()

All 10 gradient tests pass.

Closes #4802

webzuweb and others added 2 commits September 7, 2026 14:24
ManimColor.gradient() was a public static method that raised
NotImplementedError despite having a documented signature and return
type. Implement it by delegating to the module-level color_gradient(),
and add tests covering zero length, empty input, single-color input,
endpoint interpolation, and parity with the module function.

Closes ManimCommunity#4802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant