vpoints¶
- class janim.components.vpoints.Cmpt_VPoints(*args, **kwargs)¶
基类:
Cmpt_Points,Generic曲线点坐标数据
每三个点表示一段二阶贝塞尔曲线,并且前后相接的曲线共用公共点。
例如对于点坐标列表
[a, b, c, d, e, f, g],则表示这些曲线:[a, b, c][c, d, e][e, f, g]将
NAN_POINT视为子路径结束的表示。例如对于点坐标列表
[a, b, c, d, e, NAN_POINT, f, g, h],则表示两段子路径:[a, b, c, d, e]和[f, g, h]如果子路径的终止点和起始点相同,则该段子路径被视为闭合路径。
只有闭合的子路径,才能够进行填充色的渲染
- set(points: VectArray) Self¶
设置点坐标数据,每个坐标点都有三个分量
使用形如
.set([[1.5, 3, 2], [2, 1.5, 0]])的形式
- apply_points_fn(func: PointsFn, *, about_point: Vect | None = None, about_edge: Vect | None = array([0., 0., 0.]), root_only: bool = False) Self¶
将所有点作为单独的一个参数传入
func,并将func返回的结果作为新的点坐标数据视
about_point为原点,若其为None,则将物件在about_edge方向上的边界作为about_point
- classmethod align_for_interpolate(cmpt1: Cmpt_VPoints, cmpt2: Cmpt_VPoints) AlignedData[Self]¶
- interpolate(cmpt1: ~typing.Self, cmpt2: ~typing.Self, alpha: float, *, path_func: PathFunc = <function straight_path>) None¶
- static align_path(path1: ndarray, path2: ndarray) tuple[ndarray, ndarray]¶
- static insert_n_curves_to_point_list(n: int, points: VectArray) ndarray¶
- insert_n_curves(n: int, root_only=False) Self¶
- get_anchors() ndarray¶
得到曲线的锚点
- get_handles() ndarray¶
得到曲线的控制点
- property start_direction: ndarray¶
- property end_direction: ndarray¶
- close_path() Self¶
- static get_bezier_tuples_from_points(points: VectArray) Iterable[ndarray]¶
由
points得到由每一组贝塞尔曲线控制点组成的列表例如,对于有 7 个点的
points,返回值是(points[[0, 1, 2]], points[[2, 3, 4]], points[[4, 5, 6]])
- get_bezier_tuples() Iterable[ndarray]¶
得到由每一组贝塞尔曲线控制点组成的列表,具体参考
get_bezier_tuples_from_points()
- curves_count() int¶
得到曲线数量
- get_nth_curve_points(n: int) VectArray¶
得到第
n组的贝塞尔曲线控制点 (从 0 开始计数)
- get_nth_curve_function(n: int) Callable[[float], ndarray]¶
返回值是第
n组贝塞尔曲线的描点函数,传入 [0, 1] 之间的值,得到对应的在曲线上的点
- quick_point_from_proportion(alpha: float) ndarray¶
相比
point_from_proportion()而言,更快但是这里假设所有的曲线都有相同的长度,所以是不准确的
- curve_and_prop_of_partial_point(alpha: float) tuple[int, float]¶
如果你想要得到沿着整个曲线上所在比例为 alpha 处的点, 这个函数会返回这个比例所对应的曲线部分的索引,以及在这个曲线部分上需要行进的比例
- point_from_proportion(alpha: float) ndarray¶
- pointwise_become_partial(other: Cmpt_VPoints | Item, a: float, b: float) Self¶
- add_as_corners(points: VectArray) Self¶
以折线的方式将
points添加
- set_as_corners(points: VectArray) Self¶
将点数据设置为由
points构成的折线
- is_smooth(angle_tol: float = 0.017453292519943295) bool¶
- get_joint_products() ndarray¶
得到每个锚点前后方向向量的点积
- change_anchor_mode(mode: AnchorMode) Self¶
- make_smooth(approx=False, root_only=False) Self¶
Edits the path so as to pass smoothly through all the current anchor points.
If approx is False, this may increase the total number of points.
- make_approximately_smooth(root_only=False) Self¶
- make_jagged(root_only=False) Self¶
- static get_area_vector_from_points(points: ndarray) ndarray¶
- property area_vector: ndarray¶
一个向量,其长度为锚点形成的多边形所围成的面积,根据右手定则指向垂直于该多边形的方向
- property unit_normal: ndarray¶
- walk_subpath_end_indices() Generator[int, None, None]¶
遍历每个子路径结尾的下标
- get_subpath_end_indices() list[int]¶
- get_closepath_flags() ndarray¶
得到子路径是否闭合的标志,结果长度与点数量相同
对于闭合路径,结果中对应部分会被设置为
True
- static get_parts_by_end_indices(array: ndarray, end_indices: ndarray) list[ndarray]¶
根据子路径结尾下标的列表,将
array分段
- get_subpaths() list[ndarray]¶
得到子路径列表
- add_subpath(points: VectArray) Self¶
- property identity: tuple[int, ndarray]¶
- width_along_direction(direction: Vect) float¶
- same_shape(other: Cmpt_VPoints | Item) bool¶
判断两组点是否有完全相同的形状
对于相同形状的两组点还可以用
same_direction()衡量方向重合度
- same_direction(other: Cmpt_VPoints | Item) bool¶
对于
same_shape()结果为True的两组点,可以通过该方法衡量方向重合度返回
-1~1之间的值其中
1表示完全同向,-1表示完全反向,0表示垂直
注:对于
same_shape()结果为False的两组点,该方法的结果没有实际含义