manim icon indicating copy to clipboard operation
manim copied to clipboard

How to fill with gradient in shader mode?

Open BenEcon opened this issue 4 years ago • 1 comments

How to fill circle for example with gradient in shader mode? I tried set_color_by_gradient, it results in having different colors for different submobjects.

For example:

class Gradient(Scene):
    def construct(self):
        circle_1 = Circle().move_to(2*RIGHT)
        circle_2 = Circle().move_to(2*LEFT)
        circles = VGroup(circle_1,circle_2)
        self.add(circles.set_color_by_gradient(PINK, YELLOW))
        self.wait()

The results is:

https://user-images.githubusercontent.com/53943014/102837108-1a97a280-4436-11eb-83cf-72dee1fa1d3b.mp4

What I want is something like this:

568-5686766_gradient-circle-circle-hd-png-download

All suggestions are highly appreciated. Thank you.

BenEcon avatar Dec 22 '20 01:12 BenEcon

Why do you post an example with two circles, when the desired outcome is a single circle? Anyways, try

from manim import *

class Gradient(Scene):
    def construct(self):
       gradient_circle = Circle(fill_opacity=1).set_color([ORANGE, RED])
       self.add(gradient_circle)

output image

ReneTC avatar Nov 22 '23 12:11 ReneTC