line¶
- class janim.items.geometry.line.Cmpt_VPoints_LineImpl(*args, **kwargs)¶
基类:
Cmpt_VPoints,Generic在线段中,对
Cmpt_VPoints的进一步实现- put_start_and_end_on(start: Vect, end: Vect) Self¶
通过旋转和缩放,使得物件的起点和终点被置于
start和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¶
- static pointify_start_and_end(*args) tuple[ndarray, ndarray]¶
- static pointify(input, direction=None) ndarray¶
- class janim.items.geometry.line.Line(*args, **kwargs)¶
基类:
GeometryShape线段
- 参数:
- 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¶
类似传递给
__init__的参数,重新设置几何物件的形状可以缺省部分值,表示使用先前的;具体用法请参考 重设几何形状 文档教程
- static build_points(start: ndarray, end: ndarray, buff: LineBuff, path_arc: float) ndarray¶
构建线段的点数据
基于起点、终点、两端空余量和弯曲弧度生成线段的点数组
- 参数:
start -- 线段的起点坐标
end -- 线段的终点坐标
buff -- 线段两端的空余量,可为单个数值或者一个元组表示两端的空余量;可用负值表示向外延伸
path_arc -- 线段的弯曲弧度;0 即为直线,非零则是一段圆弧
- 返回:
线段的点数据数组
- static pointify_start_and_end(start: BoundingBox | Vect, end: BoundingBox | Vect) tuple[ndarray, ndarray]¶
将起点与终点输入解析为用于构造线段的三维坐标对
先基于两者的粗略位置计算方向向量,再在输入为边界框时沿该方向提取边界点,从而得到更符合连接方向的首尾点
- 参数:
start -- 起点,可为边界框对象或坐标
end -- 终点,可为边界框对象或坐标
- 返回:
解析后的
(start, end)三维坐标
- static pointify(input: BoundingBox | Vect, direction: Vect | None = None) ndarray¶
将输入解析为三维坐标点
若传入为边界框对象,未给定方向时返回中心点,给定方向时返回该方向上的边界点;若传入坐标序列,则补齐到 3 维后返回
- 参数:
input -- 边界框对象或坐标
direction -- 用于提取物件坐标,默认为
None提取其中心点,或是指定一个方向提取其边界框上指定方向的点(使用get_continuous())
- 返回:
解析得到的三维坐标
- class janim.items.geometry.line.Cmpt_VPoints_DashedLineImpl(*args, **kwargs)¶
基类:
Cmpt_VPoints_LineImpl,Generic在虚线中,对
Cmpt_VPoints的进一步实现主要是对虚线根物件没有点数据导致部分方法不可用的 patch
- get_start() ndarray¶
得到
points的第一个点
- get_end() ndarray¶
得到
points的最后一个点
- class janim.items.geometry.line.DashedLine(*args, **kwargs)¶
-
虚线
- 参数:
dash_length -- 每段虚线的长度
dashed_ratio -- 虚线段的占比,默认为
0.5,即虚线段与空白段长度相等,但可能因为虚线段描边存在粗细而导致视觉上空白长度略小strict_by_length --
虚线段长度是否严格遵从
dash_length,默认为False当为
False时,可能会微调以确保首尾都是完整的虚线段当为
True时,不再微调,但是尾部虚线段可能不完整
在静态使用的情境下,使用
False会更美观;在动态创建的情境下,使用True可以避免频繁抖动**kwargs -- 其它参数,另见
Line
警告
由于一些因素,
DashedLine并不完全具有Line的功能这是由于
DashedLine实际上将每段虚线作为子物件来实现,而去除了自己本身的points数据, 这会导致包括.points.get().anim.reshape(...)等一些方法无法得到预期的效果或不可用小技巧
虽然
.reshape(...)可用,但是.anim.reshape(...)不可用, 因此如果你要对DashedLine作用动态动画,建议使用ItemUpdater- points¶
- class janim.items.geometry.line.TangentLine(*args, **kwargs)¶
基类:
Line切线
传入
vitem表示需要做切线的物件,alpha表示切点在vitem上的比例length: 切线长度d_alpha: 精细程度,越小越精细(默认1e-6)
- class janim.items.geometry.line.Elbow(width: float = 0.2, angle: float = 0, **kwargs)¶
基类:
MarkedItem,VItem折线(一般用作直角符号),关于直接基于两条线创建的直角符号,另请参见
RightAngle- 参数:
width -- 直角标记的边长
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)¶
基类:
MarkedItem,VItem一个圆弧或直角标记对象,用于表示两条线之间的夹角
radius: 圆弧的半径quadrant:- 由两个整数构成的序列,用于确定应使用哪一个象限为基准;第一个值表示在第一条线上以终点(1)或起点(-1)为基准,第二个值同理作用于第二条线;可选值包括:
(1, 1),(1, -1),(-1, 1),(-1, -1)
other_angle:- 在两个可能的夹角之间切换。默认
False,则弧线从line1到line2按逆时针绘制;如果为True,则按顺时针方向绘制
dot: 是否在弧线上添加一个点,通常用于指示直角dot_radius: 点的半径,默认为弧半径的1/10dot_distance: 点到圆心的相对距离,其中0表示在圆心处,1表示在圆弧上,默认为0.55dot_color: 点的颜色elbow: 是否使用直角标记的形式,参考RightAngle类
- get_value(degrees: bool = False) float¶
获取该角的数值
degrees: 是否以角度的形式返回,默认为False,即弧度制