line

class janim.items.geometry.line.Cmpt_VPoints_LineImpl(*args, **kwargs)

Bases: Cmpt_VPoints, Generic

Further implementation of Cmpt_VPoints in line segments

put_start_and_end_on(start: Vect, end: Vect) Self

Through rotation and scaling, place the item’s start and end points at start and end

property vector: ndarray
property unit_vector: ndarray
property angle: float
get_projection(point: Vect) ndarray

Return projection of a point onto the line

get_slope() float
set_angle(angle: float, about_point: Vect | None = None) Self
set_length(length: float, **kwargs)
property length: float
property arc_length: float
update_by_attrs(start=None, end=None, buff=None, path_arc=None) Self
update_points_by_attrs(start=None, end=None, buff=None, path_arc=None) Self
set_buff(buff: LineBuff) Self
set_path_arc(path_arc: float) Self
set_start_and_end(start: Points | Vect, end: Points | Vect) Self
static pointify_start_and_end(*args) tuple[ndarray, ndarray]
static pointify(input, direction=None) ndarray
class janim.items.geometry.line.Line(*args, **kwargs)

Bases: GeometryShape

Line segment

Parameters:
  • start – Line start point, can be a coordinate vector or a Points object; default is LEFT

  • end – Line end point, can be a coordinate vector or a Points object; default is RIGHT

  • buff – Buffer at both ends of the line segment; can be a single value or a tuple for both ends. Negative values indicate outward extension

  • path_arc – Curvature angle of the line segment, default is 0; 0 means a straight line, non-zero means an arc

  • **kwargs – Other parameters

points
set_buff(buff: LineBuff) Self
set_path_arc(path_arc: float) Self
set_start_and_end(start: Points | Vect, end: Points | Vect) Self
reshape(start: Points | Vect | None = None, end: Points | Vect | None = None, *, buff: LineBuff | None = None, path_arc: float | None = None) Self

Similar to passing parameters to __init__, reset the shape of the geometry item

Some values can be omitted to reuse previous ones; for detailed usage, refer to the Reshape Geometry tutorial

static build_points(start: ndarray, end: ndarray, buff: LineBuff, path_arc: float) ndarray

Build point data for the line segment

Generate the line segment point array from start/end points, end margins, and curvature

Parameters:
  • start – Start-point coordinate of the line segment

  • end – End-point coordinate of the line segment

  • buff – Buffer at both ends of the line segment; can be a single value or a tuple for both ends. Negative values indicate outward extension

  • path_arc – Curvature angle of the line segment; 0 means a straight line, non-zero means an arc

Returns:

Point-data array of the line segment

static pointify_start_and_end(start: BoundingBox | Vect, end: BoundingBox | Vect) tuple[ndarray, ndarray]

Parse start/end inputs into a pair of 3D coordinates for constructing a line segment

First compute a direction vector from their rough positions, then if the inputs are bounding boxes, extract boundary points along that direction to get endpoints that better match the connection direction

Parameters:
  • start – Start point, can be a bounding-box object or coordinates

  • end – End point, can be a bounding-box object or coordinates

Returns:

Parsed (start, end) 3D coordinates

static pointify(input: BoundingBox | Vect, direction: Vect | None = None) ndarray

Parse input into a 3D coordinate point

If a bounding-box object is passed, return its center when no direction is given, or return the boundary point in that direction when a direction is given; if a coordinate sequence is passed, pad it to 3D and return

Parameters:
  • input – Bounding-box object or coordinates

  • direction – Used to extract item coordinates. Default None extracts the center point; or specify a direction to extract the point on the bounding box in that direction (using get_continuous())

Returns:

Parsed 3D coordinates

class janim.items.geometry.line.Cmpt_VPoints_DashedLineImpl(*args, **kwargs)

Bases: Cmpt_VPoints_LineImpl, Generic

Further implementation of Cmpt_VPoints in dashed lines

Patch to fix some methods being unavailable because the dashed line’s root item lacks point data

get_start() ndarray

Get the first point of points

get_end() ndarray

Get the last point of points

class janim.items.geometry.line.DashedLine(*args, **kwargs)

Bases: Line, Group[VItem]

Dashed line

Parameters:
  • dash_length – Length of each dash segment

  • dashed_ratio – Ratio of dash segments, default is 0.5, meaning dash segments and gaps have equal length, but the visual gap length may appear slightly smaller due to stroke size

  • strict_by_length – Whether the dash segment length strictly follows dash_length, default is False - When False, may fine-tune to ensure both ends have complete dash segments - When True, no fine-tuning, but the trailing dash segment may be incomplete. For static use, False looks better; for dynamic creation, True avoids frequent jittering

  • **kwargs – Other parameters, see also Line

Warning

Due to some reasons, DashedLine does not fully have all capabilities of Line

This is because DashedLine is implemented by treating each dash segment as a child item and removing its own points data, which causes some methods, such as .points.get() and .anim.reshape(...), to not work as expected or be unavailable.

Tip

Although .reshape(...) is available, .anim.reshape(...) is not. Therefore, if you want to apply dynamic animations to DashedLine, it is recommended to use ItemUpdater.

points
reshape(start: Points | Vect | None = None, end: Points | Vect | None = None, *, buff: LineBuff | None = None, path_arc: float | None = None) Self

Similar to passing parameters to __init__, reset the shape of the geometry item

Some values can be omitted to reuse previous ones; for detailed usage, refer to the Reshape Geometry tutorial

class janim.items.geometry.line.TangentLine(*args, **kwargs)

Bases: Line

Tangent line

  • Pass vitem as the item to create a tangent line for, alpha represents the proportion of the tangent point on vitem

  • length: Length of the tangent line

  • d_alpha: Precision level, smaller values mean higher precision (default 1e-6)

class janim.items.geometry.line.Elbow(width: float = 0.2, angle: float = 0, **kwargs)

Bases: MarkedItem, VItem

Elbow (generally used as a right angle symbol). For right angle symbols created directly from two lines, see also RightAngle

Parameters:
  • width – Side length of the right angle marker

  • angle – Starting angle

class janim.items.geometry.line.Angle(line1: Line, line2: Line, radius: float | None = None, quadrant: AngleQuadrant = (1, 1), other_angle: bool = False, dot: bool = False, dot_radius: float | None = None, dot_distance: float = 0.55, dot_color: JAnimColor = '#FFFFFF', elbow: bool = False, **kwargs)

Bases: MarkedItem, VItem

An arc or right angle marker object used to represent the angle between two lines

  • radius: Radius of the arc

  • quadrant:
    A sequence of two integers used to determine which quadrant to use as reference;
    The first value indicates using the end point (1) or start point (-1) as reference on the first line, the second value similarly applies to the second line;
    Optional values include: (1, 1), (1, -1), (-1, 1), (-1, -1)
  • other_angle:
    Switch between two possible angles. Default False means the arc is drawn counterclockwise from line1 to line2;
    If True, draw in clockwise direction
  • dot: Whether to add a dot on the arc, usually used to indicate a right angle

  • dot_radius: Radius of the dot, default is 1/10 of the arc radius

  • dot_distance: Relative distance from the dot to the center, where 0 means at the center, 1 means on the arc, default is 0.55

  • dot_color: Color of the dot

  • elbow: Whether to use the right angle marker form, refer to RightAngle class

get_lines() Group

Return a Group object containing the two Line objects that form this angle

get_value(degrees: bool = False) float

Get the numerical value of this angle

  • degrees: Whether to return in degrees, default is False, i.e., radians

static from_three_points(A: Vect, B: Vect, C: Vect, **kwargs) Angle

Construct an angle from three points, representing ∠ABC, where point B is the vertex

class janim.items.geometry.line.RightAngle(line1: Line, line2: Line, length: float | None = None, **kwargs)

Bases: Angle

An object in Elbow style (L-shaped corner) used to represent a right angle

  • length: Side length of the right angle marker