%%manim -qm TestGlsl
class TestGlsl(Scene):
def construct(self):
# square = Square(side_length=1)
colors = [RED, BLUE, YELLOW]
palette = color_gradient(colors, 10)
grp = VGroup(*[
Square(color=c, fill_opacity=1)
for c in palette
]).arrange(RIGHT).set(width=config.frame_width-1)
sq = Square(side_length=2).set_color_by_gradient(colors)
self.add( sq,grp)
my_square = Square(side_length=2)
my_square.set_color_by_gradient(colors)
my_square.set_sheen_direction(LEFT) # Sets the gradient to go from left to right
# self.play(Create(my_square))
square = Square() # Create a square
# Get the coordinates of the corners
DL = square.get_bottom() + square.get_left()
DR = square.get_bottom() + square.get_right()
UL = square.get_top() + square.get_left()
UR = square.get_top() + square.get_right()
# Create dots at the corners and color them
bottom_left_dot = Dot(DL).set_color_by_gradient(colors)
bottom_right_dot = Dot(DR, color=GREEN)
upper_left_dot = Dot(UL, color=BLUE)
upper_right_dot = Dot(UR, color=YELLOW)
# Add everything to the scene
self.add(square, bottom_left_dot, bottom_right_dot, upper_left_dot, upper_right_dot)
dashed_1 = DashedLine(
start=LEFT * 2,
end=RIGHT * 2,
dash_length=0.8 # Longer dashes
).shift(UP*2)
# Create a dashed line with a smaller dash-to-space ratio
dashed_2 = DashedLine(
start=LEFT * 2,
end=RIGHT * 2,
dashed_ratio=0.3 # More space between dashes
).shift(DOWN)
self.add(dashed_1, dashed_2)