Search code examples
pythonmanim

Draw lines with manim library?


I started learning manim and I hope you could help me understand how this code works

class Line_1(Scene):
    def construct(self):
        path = Line(LEFT*5,RIGHT*5,stroke_opatity=0.5)
        path.points[1:3] += UP*2
        self.add(path)

When I run the code I get this: enter image description here

However I do not know how to interpret this "path.points[1:3] += UP*2" What does it mean .points[1:3]?

Thanks in advance


Solution

  • All VMobjects (Lines, Circles, etc) are Bezier curves, and all Bezier curves have control points, those control points are in the .points attribute, the lines have 4 control points, and what that code does is to move the intermediate control points (I do not move the ends).