几何类原创
# Line
line_1 = Line() # 默认情况下是从二维坐标(-1,0)到(1,0)的一条线段
line_2 = Line(start,end) # start 起点坐标 end 终点坐标 坐标需要使用 np.array([x,y,z])
line_2 = Line(start,end,stroke_width=6) # stroke_width线的粗线
line_3 = Line(start,end,path_arc=0.5) # 弧线, path_arc 弧度参数
line_1.put_strat_and_end_on(start,end) # 两点确定一条直线
line_1.scale(2) # 只会改变长度,不会改变粗细
line_4 = DashedLine(s,e) // DashedLine 虚线,参数同 line
# arrow
带箭头的线段
line_1 = Arrow(rear,hear) # rear 尾部坐标 hear 头部坐标 坐标需要使用 np.array([x,y,z])
line_2 = Line(rear,hear)
line_2.add_tip() # 效果同 line_1 , 只是粗细与缓冲有区别
line_3 = Arrow(rear,hear,buff=1) # Arrow 默认 buff 0.25
line_3 = Arrow(rear,hear,buff=1, tip_length=2) # Arrow 默认 tip_length ,改变箭头大小
line_3 = Arrow(rear,hear,buff=1, max_tip_lenght_to_length_ratio=2) # Arrow 默认 max_tip_lenght_to_length_ratio ,可以在线长不变的情况下设置箭头的最大大小比例
line_1 = DoubleArrow(rear,hear) # 双箭头
# arc
圆弧
arc_1 = Arc(angle = TAU/3)
arc_1.add_top() # 为圆弧添加箭头
arc_1.add_top(at_start=true) # 为弧尾添加箭头
cir = Circle() # 画圆
line_1 = TangentiLine(cir,alpha=0,lenght=5) # 在 cir 上画切线;alpha 0~1 控制角度
# AnnularSector() 环形弧
# ArcBetweenPoints(start,end,angle) 两点画弧
# CuredArrow(start,end,angle) 单箭头弧
# CuredDoubleArrow(start,end,angle) 双箭头弧
# 通过 add_tip 添加 CuredArrow 和 CuredDoubleArrow
# arc 参数
Arc(arc_center=ORINGIN, radius=1, stroke_width=4,start_angle=0DEGREES,angle=90DEGREES,color=WHITE)
- arc_center 控制圆心位置
- radius 控制半径
- stroke_width 线粗细
- start_angle 开始角度
- angle 弧度
- color 颜色
# Circle
圆
Circle(arc_center=ORINGIN, radius=1, stroke_width=4, stroke_color=RED, fill_color=RED, fill_opacity=0)
- arc_center 控制圆心位置
- radius 控制半径
- stroke_width 线粗细
- stroke_color 边框颜色
- fill_color 填充颜色
- fill_opacity 填充透明度
# dot
点
Dot(arc_center=ORINGIN, radius=1, stroke_width=0, fill_color=RED, fill_opacity=0)
- arc_center 控制圆心位置
- stroke_width 线粗细
- fill_color 填充颜色,默认白色
- fill_opacity 填充透明度
# Ellipse
椭圆
Ellipse(width=1,height=2,arc_center=ORINGIN, radius=1, stroke_width=0, fill_color=RED, fill_opacity=0)
- width 宽度
- height 高度
- arc_center 控制圆心位置
- stroke_width 线粗细
- fill_color 填充颜色,默认白色
- fill_opacity 填充透明度
# Annulus
圆环类
Annulus(outer_radius=1, inner_radius=1, stroke_width=0, stroke_color=RED, fill_color=RED, fill_opacity=0)
- outer_radius 外环半径
- inner_radius 内环半径
- stroke_width 线粗细
- stroke_color 线颜色
- fill_color 填充颜色,默认白色
- fill_opacity 填充透明度
# AnnulularSector
环扇形类
AnnulularSector(outer_radius=1, inner_radius=1, start_angle=PI/6, angle=PI/3 stroke_width=0, stroke_color=RED, fill_color=RED, fill_opacity=0)
- outer_radius 外环半径
- inner_radius 内环半径
- start_angle 开始角度
- angle 弧度
- stroke_width 线粗细
- stroke_color 线颜色
- fill_color 填充颜色,默认白色
- fill_opacity 填充透明度
# Sector
扇形
AnnulularSector(outer_radius=1, start_angle=PI/6, angle=PI/3 stroke_width=0, stroke_color=RED, fill_color=RED, fill_opacity=0)
- outer_radius 外环半径
- start_angle 开始角度
- angle 弧度
- stroke_width 线粗细
- stroke_color 线颜色
- fill_color 填充颜色,默认白色
- fill_opacity 填充透明度
# Polygon
多边形
polygon(p1,p2,p3,...,pn) // 至少3个点以上
.set_fill(color=XXXX)
.set_fill(opacity=X)
.set_stroke(color=XXXX,width=x)
.round_corners(x) # 各顶点的圆角大小
# 渐变
用于多边形中,方法传参
sheen_factor=4, sheen_direction=UL # sheen_factor 渐变因子大小 sheen_direction 渐变方向
# add_tip