本文整理汇总了Python中Polygon.Polygon.covers方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.covers方法的具体用法?Python Polygon.covers怎么用?Python Polygon.covers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.covers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import covers [as 别名]
#.........这里部分代码省略.........
----------
dt : float
"""
self.translate(dt * self.velocity)
self.rotate(dt * self.angular_velocity)
def enable(self, enabled):
"""Set whether the shape should be drawn.
Parameters
----------
enabled : bool
"""
self.enabled = enabled
return self
def overlaps(self, other):
"""Check if two shapes overlap.
Parameters
----------
other : |Shape|
Returns
-------
bool
"""
return bool(self.poly.overlaps(other.poly))
def covers(self, other):
"""Check if the shape completely covers another shape.
Parameters
----------
other : |Shape|
Returns
-------
bool
"""
return bool(self.poly.covers(other.poly))
def __repr__(self):
kwarg_strs = []
for arg, value in self._kwargs.items():
if isinstance(value, str):
value_str = "'{}'".format(value)
elif isinstance(value, np.ndarray):
value_str = "[{}, {}]".format(*value)
else:
value_str = str(value)
kwarg_strs.append(arg + "=" + value_str)
kwargs = ",\n" + ", ".join(kwarg_strs)
return "{cls}({points}{kwargs})".format(
cls=type(self).__name__,
points="[{}]".format(",\n".join("[{}, {}]".format(x, y) for x, y in self.vertices)),
kwargs=kwargs,
)
def __eq__(self, other):
示例2: text
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import covers [as 别名]
#.........这里部分代码省略.........
if lc >= 4:
mli = 0
maxl = 0
lengths = []
for i in range(len(contours)):
totlen = lenctr(contours[i])
lengths.append((totlen,i))
if totlen > maxl:
mli = i
maxl = totlen
lengths.sort()
lengths.reverse()
ocontours = []
for ll in lengths:
ocontours.append(contours[ll[1]])
contours = ocontours
indxf = -1
indxc = -1
if (mli > 0 and newchar != "%"):
try: indxf = excludef_list.index(self.font)
except: pass
if indxf == -1:
try: indxc = excludec_list.index((self.font, newchar))
except: pass
if (indxf == -1 and indxc == -1):
maxc = contours.pop(mli)
contours.insert(0, maxc)
a = Polygon(contours[0])
for i in range(1,len(contours)):
b = Polygon(contours[i])
if a.covers(b): a = a - b
elif b.covers(a): a = b - a
else: a = a + b
a.shift(bb - a.boundingBox()[0] ,0)
ptext[line] += a
bx = ptext[line].boundingBox()
bb = bx[1] - bx[0] + spacing*fontheight
newwidth = fontscale*height*(ptext[line].boundingBox()[1]-ptext[line].boundingBox()[0])
widths.append(newwidth)
if newwidth > width: width = newwidth
ptext[line].scale(xscale*fontscale*height, yscale*fontscale*height, 0, 0)
for line in range(len(lines)):
if align == 'left':
ptext[line].shift(-width/2,-line*vertical_spacing)
elif align == 'right':
ptext[line].shift(width/2-widths[line],-line*vertical_spacing)
else:
ptext[line].shift(-widths[line]/2,-line*vertical_spacing)
ptext[line].shift(pos[0], pos[1])
if rotate != 0.0: ptext[line].rotate(rotate)
if line == 0:
shape = ptext[0]
upper_left = vis.vector(ptext[line].boundingBox()[0],ptext[line].boundingBox()[3],0)
upper_right = vis.vector(ptext[line].boundingBox()[1],ptext[line].boundingBox()[3],0)
lower_left = vis.vector(ptext[line].boundingBox()[0],ptext[line].boundingBox()[2],0)
lower_right = vis.vector(ptext[line].boundingBox()[1],ptext[line].boundingBox()[2],0)
else: