Skip to content

New Feature: Added support for Radial Gradient - #4941

Open
UnMolDeQuimica wants to merge 6 commits into
ManimCommunity:mainfrom
UnMolDeQuimica:feat_add_gradient_objects
Open

New Feature: Added support for Radial Gradient#4941
UnMolDeQuimica wants to merge 6 commits into
ManimCommunity:mainfrom
UnMolDeQuimica:feat_add_gradient_objects

Conversation

@UnMolDeQuimica

@UnMolDeQuimica UnMolDeQuimica commented Aug 16, 2026

Copy link
Copy Markdown

Overview: What does this pull request change?

Adds support for radial gradients with Cairo renderer.

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

Currently, ManimCE supports only linear gradients and it supports them in a very clunky way. In this PR I add a small step towards improving how gradients work by adding a GradientType enum and implementing support for radial gradients.

Here's an example of what can be done with these changes:

class GradientVariants(Scene):
    def construct(self):
        gradient = color_gradient([RED, GREEN, BLUE], 3)
        circles = VGroup(*[
            Circle(
                fill_opacity=1,
                fill_color=gradient, 
                stroke_opacity=0,
                gradient_type=gradient_type,
                sheen_direction=RIGHT
            ).scale(2)
            for gradient_type in GradientType
        ])
        circles.arrange(RIGHT, buff=1)
        self.add(circles)
        for circle in circles:
            label = Text(
                circle.gradient_type.name,
                font_size=24
            ).next_to(circle, DOWN)
            self.add(label)
image

This example is added to the documentation.

Links to added or changed documentation pages

GradientType documentation

Updated VMobject documentation

Further Information and Comments

All tests pass as I made it use the LINEAR gradient type by default to support existing code.

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

Small note: I did not add tests, just ran existing tests and tried a few combinations

@UnMolDeQuimica

UnMolDeQuimica commented Aug 16, 2026

Copy link
Copy Markdown
Author

I recently added another PR with modifications to support the alpha value of a ManimColor inside a VMobject. Combining both functionalities, things like this are possible:

from manim import *


class GradientExample(Scene):
    def construct(self):
        gradient = color_gradient(
            [
                ManimColor("#f7f7b6"),
                ManimColor("#ffff00"),
                ManimColor("#ffff00", alpha=0),
                ManimColor("#ffff00", alpha=0),
                ManimColor("#ffff00", alpha=0),
            ],
            5
        )

        self.add(
            Circle(
                radius=4,
                fill_color=gradient,
                fill_opacity=1,
                gradient_type=GradientType.RADIAL,
                stroke_opacity=0,
            )
        )
GradientExample_ManimCE_v0 21 0

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.

1 participant