本文整理汇总了Python中nodebox.graphics.Path.cornerRect方法的典型用法代码示例。如果您正苦于以下问题:Python Path.cornerRect方法的具体用法?Python Path.cornerRect怎么用?Python Path.cornerRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nodebox.graphics.Path
的用法示例。
在下文中一共展示了Path.cornerRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shape_intersects
# 需要导入模块: from nodebox.graphics import Path [as 别名]
# 或者: from nodebox.graphics.Path import cornerRect [as 别名]
def shape_intersects(distance):
tx, ty = coordinates(0, 0, distance, angle)
t = Transform()
t.translate(tx, ty)
translated_shape = t.map(shape)
if use_bounding_box:
b = Path()
b.cornerRect(translated_shape.bounds)
else:
b = translated_shape
# If the shape intersects it is too close (the distance is too low).
if bounding_path.intersects(b):
return -1
return 1
示例2: angle_pack
# 需要导入模块: from nodebox.graphics import Path [as 别名]
# 或者: from nodebox.graphics.Path import cornerRect [as 别名]
def angle_pack(shapes, seed, limit, maximum_radius, angle_tries=1, use_bounding_box=False):
if shapes is None: return None
_seed(seed)
def center_and_translate(shape, tx=0, ty=0):
bx, by, bw, bh = list(shape.bounds)
t = Transform()
t.translate(-bw / 2 - bx, -bh / 2 - by)
return t.map(shape)
geo = Geometry()
bounding_path = Path()
# Center first shape
first_shape = center_and_translate(shapes[0])
geo.add(first_shape)
bounding_path.cornerRect(first_shape.bounds)
for shape in shapes[1:]:
centered_shape = center_and_translate(shape)
angles = []
for i in range(angle_tries):
a = uniform(0, 360)
if use_bounding_box:
d = try_angle(bounding_path, centered_shape, a, limit, maximum_radius, use_bounding_box)
else:
d = try_angle(geo, centered_shape, a, limit, maximum_radius, use_bounding_box)
angles.append([d, a])
chosen_distance, chosen_angle = sorted(angles)[0]
tx, ty = coordinates(0, 0, chosen_distance, chosen_angle)
t = Transform()
t.translate(tx, ty)
translated_shape = t.map(centered_shape)
bounding_path.cornerRect(translated_shape.bounds)
geo.add(translated_shape)
return geo