本文整理汇总了Python中mobject.vectorized_mobject.VMobject.get_anchors方法的典型用法代码示例。如果您正苦于以下问题:Python VMobject.get_anchors方法的具体用法?Python VMobject.get_anchors怎么用?Python VMobject.get_anchors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.vectorized_mobject.VMobject
的用法示例。
在下文中一共展示了VMobject.get_anchors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Arrow
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import get_anchors [as 别名]
class Arrow(Line):
CONFIG = {
"color" : YELLOW_C,
"tip_length" : 0.25,
"tip_angle" : np.pi/6,
"buff" : MED_SMALL_BUFF,
"propogate_style_to_family" : False,
"preserve_tip_size_when_scaling" : True,
}
def __init__(self, *args, **kwargs):
points = map(self.pointify, args)
if len(args) == 1:
args = (points[0]+UP+LEFT, points[0])
Line.__init__(self, *args, **kwargs)
self.add_tip()
def add_tip(self, add_at_end = True):
vect = self.tip_length*RIGHT
vect = rotate_vector(vect, self.get_angle()+np.pi)
start, end = self.get_start_and_end()
if not add_at_end:
start, end = end, start
vect = -vect
tip_points = [
end+rotate_vector(vect, u*self.tip_angle)
for u in 1, -1
]
self.tip = VMobject(
close_new_points = True,
mark_paths_closed = True,
fill_color = self.color,
fill_opacity = 1,
stroke_color = self.color,
)
self.tip.set_anchor_points(
[tip_points[0], end, tip_points[1]],
mode = "corners"
)
self.set_points_as_corners(
[start, center_of_mass(tip_points)]
)
self.add(self.tip)
self.init_colors()
def get_end(self):
if hasattr(self, "tip"):
return self.tip.get_anchors()[1]
else:
return Line.get_end(self)
def get_tip(self):
return self.tip
def scale(self, scale_factor, **kwargs):
Line.scale(self, scale_factor, **kwargs)
if self.preserve_tip_size_when_scaling:
self.remove(self.tip)
self.add_tip()
return self