本文整理汇总了Python中mobject.Mobject.add_points方法的典型用法代码示例。如果您正苦于以下问题:Python Mobject.add_points方法的具体用法?Python Mobject.add_points怎么用?Python Mobject.add_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.Mobject
的用法示例。
在下文中一共展示了Mobject.add_points方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Flash
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import add_points [as 别名]
class Flash(Animation):
CONFIG = {
"color" : "white",
"slow_factor" : 0.01,
"run_time" : 0.1,
"rate_func" : None,
}
def __init__(self, mobject, **kwargs):
self.intermediate = Mobject(color = self.color)
self.intermediate.add_points([
point + (x, y, 0)
for point in self.mobject.points
for x in [-1, 1]
for y in [-1, 1]
])
Animation.__init__(self, mobject, **kwargs)
def update_mobject(self, alpha):
#Makes alpha go from 0 to slow_factor to 0 instead of 0 to 1
alpha = self.slow_factor * (1.0 - 4 * (alpha - 0.5)**2)
self.mobject.interpolate(
self.starting_mobject,
self.intermediate,
alpha
)
示例2: get_circles_and_points
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import add_points [as 别名]
def get_circles_and_points(self, min_input, max_input):
input_left, input_right = [
self.interval.number_to_point(num)
for num in min_input, max_input
]
input_circle = Circle(
radius = np.linalg.norm(input_left-input_right)/2,
color = WHITE
)
input_circle.shift((input_left+input_right)/2)
input_points = Line(
input_left, input_right,
color = self.input_color
)
output_points = Mobject(color = self.output_color)
n = self.output.get_num_points()
output_points.add_points(
self.output.points[int(min_input*n):int(max_input*n)]
)
output_center = output_points.points[int(0.5*output_points.get_num_points())]
max_distance = np.linalg.norm(output_center-output_points.points[-1])
output_circle = Circle(
radius = max_distance,
color = WHITE
)
output_circle.shift(output_center)
return (
input_circle,
input_points,
output_circle,
output_points
)
示例3: nearest_neighbor_align
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import add_points [as 别名]
def nearest_neighbor_align(mobject1, mobject2):
distance_matrix = cdist(mobject1.points, mobject2.points)
closest_point_indices = np.apply_along_axis(
np.argmin, 0, distance_matrix
)
new_mob1 = Mobject()
new_mob2 = Mobject()
for n in range(mobject1.get_num_points()):
indices = (closest_point_indices == n)
new_mob1.add_points(
[mobject1.points[n]]*sum(indices)
)
new_mob2.add_points(
mobject2.points[indices],
rgbs = mobject2.rgbs[indices]
)
return new_mob1, new_mob2