Skip to content

Conversation

@bliyanto
Copy link

@bliyanto bliyanto commented Apr 23, 2025

Overview: What does this pull request change?

This PR fixes incorrect gradient ordering on VMobject descendants (Issue #4198) and adds first-class support for multi-stop gradients on short or dashed lines.

  • Deterministic start → end colour mapping for any list passed to set_color(...) or set_stroke(...).
  • Automatic curve subdivision when a multi-stop gradient is requested on objects with < 50 anchor points, preventing “banding”.
  • New regression tests (tests/test_gradient_order.py) to lock-in behaviour.
  • A minimal demo scene (gradient_demo.py) for manual visual inspection.

Bug: multi-stop gradients sometimes appeared reversed or compressed when applied via set_color()/set_stroke() to Line, DashedLine, or other VMobjects.

Motivation and Explanation: Why and how do your changes improve the library?

Educators rely on gradients to indicate directionality; a flipped gradient can mislead viewers or hide content.
The root cause was that update_rgbas_array() relied on the existing RGBA buffer length, which for a newly-created Line is only four points (anchors+handles), far fewer than pixels rendered.
The patch:
1.Guarantees the internal RGBA buffer always has one row per point.
2. If the user supplies > 1 colour and the object has fewer than 50 points, we call insert_n_curves() to increase resolution before interpolating the gradient.
3. Uses the explicit colour list order to generate color_gradient, ensuring the first list element lands on the first point, last on the last point.

No public API is broken, single-colour strokes and fills behave exactly as before.

Links to added or changed documentation pages

manim/types/vectorized_mobject.py

Further Information and Comments

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

Sorry, something went wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you even watched what your computer did?

I give you a hint, you just deleted all config related unit tests that has nothing to do with colors or gradients...

@bliyanto bliyanto closed this Jul 21, 2025
@github-project-automation github-project-automation bot moved this from 🆕 New to ❌ Rejected in Dev Board Jul 21, 2025
@bliyanto bliyanto deleted the fix-gradient-set-color branch July 21, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Rejected

Development

Successfully merging this pull request may close these issues.

None yet

2 participants