line¶
- class janim.items.geometry.line.Cmpt_VPoints_LineImpl(*args, **kwargs)¶
Bases:
Cmpt_VPoints,GenericFurther implementation of
Cmpt_VPointsin 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
startandend
- 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¶
- static pointify_start_and_end(*args) tuple[ndarray, ndarray]¶
- static pointify(input, direction=None) ndarray¶
- class janim.items.geometry.line.Line(*args, **kwargs)¶
Bases:
GeometryShapeLine segment
- Parameters:
start – Line start point, can be a coordinate vector or a
Pointsobject; default isLEFTend – Line end point, can be a coordinate vector or a
Pointsobject; default isRIGHTbuff – 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;0means a straight line, non-zero means an arc**kwargs – Other parameters
- points¶
- set_buff(buff: LineBuff) Self¶
- set_path_arc(path_arc: float) 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 itemSome 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
Noneextracts the center point; or specify a direction to extract the point on the bounding box in that direction (usingget_continuous())
- Returns:
Parsed 3D coordinates
- class janim.items.geometry.line.Cmpt_VPoints_DashedLineImpl(*args, **kwargs)¶
Bases:
Cmpt_VPoints_LineImpl,GenericFurther implementation of
Cmpt_VPointsin dashed linesPatch 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)¶
-
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 sizestrict_by_length – Whether the dash segment length strictly follows
dash_length, default isFalse- WhenFalse, may fine-tune to ensure both ends have complete dash segments - WhenTrue, no fine-tuning, but the trailing dash segment may be incomplete. For static use,Falselooks better; for dynamic creation,Trueavoids frequent jittering**kwargs – Other parameters, see also
Line
Warning
Due to some reasons,
DashedLinedoes not fully have all capabilities ofLineThis is because
DashedLineis implemented by treating each dash segment as a child item and removing its ownpointsdata, 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 toDashedLine, it is recommended to useItemUpdater.- 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 itemSome 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:
LineTangent line
Pass
vitemas the item to create a tangent line for,alpharepresents the proportion of the tangent point onvitemlength: Length of the tangent lined_alpha: Precision level, smaller values mean higher precision (default1e-6)
- class janim.items.geometry.line.Elbow(width: float = 0.2, angle: float = 0, **kwargs)¶
Bases:
MarkedItem,VItemElbow (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,VItemAn arc or right angle marker object used to represent the angle between two lines
radius: Radius of the arcquadrant:- 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
Falsemeans the arc is drawn counterclockwise fromline1toline2;IfTrue, draw in clockwise direction
dot: Whether to add a dot on the arc, usually used to indicate a right angledot_radius: Radius of the dot, default is1/10of the arc radiusdot_distance: Relative distance from the dot to the center, where0means at the center,1means on the arc, default is0.55dot_color: Color of the dotelbow: Whether to use the right angle marker form, refer toRightAngleclass
- get_value(degrees: bool = False) float¶
Get the numerical value of this angle
degrees: Whether to return in degrees, default isFalse, i.e., radians