Line#

Qualified name: manim.mobject.geometry.line.Line

class Line(start=array([- 1., 0., 0.]), end=array([1., 0., 0.]), buff=0, path_arc=None, **kwargs)[source]#

Bases: TipableVMobject

Methods

generate_points

Initializes points and therefore the shape.

get_angle

get_projection

Returns the projection of a point onto a line.

get_slope

get_unit_vector

get_vector

init_points

Initializes points and therefore the shape.

put_start_and_end_on

Sets starts and end coordinates of a line.

set_angle

set_length

set_path_arc

set_points_by_ends

Attributes

animate

Used to animate the application of any method of self.

animation_overrides

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

n_points_per_curve

sheen_factor

stroke_color

width

The width of the mobject.

Parameters:
  • start (Point3D) –

  • end (Point3D) –

  • buff (float) –

  • path_arc (float | None) –

_original__init__(start=array([- 1., 0., 0.]), end=array([1., 0., 0.]), buff=0, path_arc=None, **kwargs)#

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • start (Point3D) –

  • end (Point3D) –

  • buff (float) –

  • path_arc (float | None) –

Return type:

None

_pointify(mob_or_point, direction=None)[source]#

Transforms a mobject into its corresponding point. Does nothing if a point is passed.

direction determines the location of the point along its bounding box in that direction.

Parameters:
  • mob_or_point (Mobject | Point3D) – The mobject or point.

  • direction (Vector | None) – The direction.

Return type:

Point3D

generate_points()[source]#

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

Return type:

None

get_projection(point)[source]#

Returns the projection of a point onto a line.

Parameters:

point (Point3D) – The point to which the line is projected.

Return type:

Vector

init_points()#

Initializes points and therefore the shape.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

Return type:

None

put_start_and_end_on(start, end)[source]#

Sets starts and end coordinates of a line.

Examples

Example: LineExample

from manim import *

class LineExample(Scene):
    def construct(self):
        d = VGroup()
        for i in range(0,10):
            d.add(Dot())
        d.arrange_in_grid(buff=1)
        self.add(d)
        l= Line(d[0], d[1])
        self.add(l)
        self.wait()
        l.put_start_and_end_on(d[1].get_center(), d[2].get_center())
        self.wait()
        l.put_start_and_end_on(d[4].get_center(), d[7].get_center())
        self.wait()
class LineExample(Scene):
    def construct(self):
        d = VGroup()
        for i in range(0,10):
            d.add(Dot())
        d.arrange_in_grid(buff=1)
        self.add(d)
        l= Line(d[0], d[1])
        self.add(l)
        self.wait()
        l.put_start_and_end_on(d[1].get_center(), d[2].get_center())
        self.wait()
        l.put_start_and_end_on(d[4].get_center(), d[7].get_center())
        self.wait()

Parameters:
  • start (Point3D) –

  • end (Point3D) –

Return type:

Self