本文整理汇总了Python中shape.Shape.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.__init__方法的具体用法?Python Shape.__init__怎么用?Python Shape.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self):
def initHandle(handle):
self.handles.append(handle)
QObject.connect(handle, SIGNAL("moved(QGraphicsObject*)"), self.handleMoved)
Shape.__init__(self, BubbleItem(self))
# Item
self.item.setFlag(QGraphicsItem.ItemIsSelectable)
self.item.setBrush(COLOR)
# Text item
self.textItem = QGraphicsTextItem(self.item)
self.textItem.setTextInteractionFlags(Qt.TextEditorInteraction)
QObject.connect(self.textItem.document(), SIGNAL("contentsChanged()"), \
self.adjustSizeFromText)
# Handles
self.anchorHandle = Handle(self.item, 0, 0)
# Position the bubble to the right of the anchor so that it can grow
# vertically without overflowing the anchor
self.bubbleHandle = Handle(self.item, ANCHOR_THICKNESS, -ANCHOR_THICKNESS)
initHandle(self.anchorHandle)
initHandle(self.bubbleHandle)
self.setHandlesVisible(False)
self.adjustSizeFromText()
示例2: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, size, rotation, color="blue"):
texture_path = Shape.build_texture_path(color, Octagon.shape_type)
Shape.__init__(self, texture_path, size, rotation, Octagon.shape_type, color)
self.sides = 8
self.color = color
示例3: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, geometricName, contour):
Shape.__init__(self, geometricName, contour)
cornerList = []
self.minX = 1000
self.maxX = 0
self.minY = 1000
self.maxY = 0
contourCopy = contour
if len(contourCopy) > 1:
for corner in contourCopy:
cornerList.append((corner.item(0), corner.item(1)))
for corner in cornerList:
if corner[0] > self.maxX:
self.maxX = corner[0]
if corner[1] > self.maxY:
self.maxY = corner[1]
if corner[0] < self.minX:
self.minX = corner[0]
if corner[1] < self.minY:
self.minY = corner[1]
else:
self.minX = 0
self.maxX = 960
self.minY = 0
self.maxY = 720
示例4: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, ps, color=None):
Shape.__init__(self, color)
self.vs = ps
self.bound = AABox.from_vectors(*self.vs)
self.half_planes = []
for i in xrange(len(self.vs)):
h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
self.half_planes.append(h)
示例5: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, ps, color=None):
Shape.__init__(self, color)
mn = min(enumerate(ps), key=lambda (i,v): (v.y, v.x))[0]
self.vs = list(ps[mn:]) + list(ps[:mn])
self.bound = Vector.union(*self.vs)
self.half_planes = []
for i in xrange(len(self.vs)):
h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
self.half_planes.append(h)
示例6: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, theta1=0, theta2=360, *args, **kwargs):
'''Create an ellipse '''
self._theta1 = theta1
self._theta2 = theta2
Shape.__init__(self, *args, **kwargs)
self._fill_mode = GL_TRIANGLES
self._line_mode = GL_LINE_LOOP
self._update_position()
self._update_shape()
示例7: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self):
Shape.__init__(self, LineItem(self))
self.item.setFlag(QGraphicsItem.ItemIsSelectable)
self.handles.append(Handle(self.item, 0, 0))
self.handles.append(Handle(self.item, 0, 0))
self.handles[1].setZValue(self.handles[0].zValue() + 1)
for handle in self.handles:
QObject.connect(handle, SIGNAL("moved(QGraphicsObject*)"), self.handleMoved)
self.setHandlesVisible(False)
示例8: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, radius=0, *args, **kwargs):
'''Create an (optionable) round rectangle.
:Parameters:
`radius` : int or tuple of 4 int
Radius of corners.
'''
self._radius = radius
Shape.__init__(self,*args,**kwargs)
self._update_position()
self._update_shape()
示例9: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, corners):
"""
Create Square self with vertices corners.
Assume all sides are equal and corners are square.
@param Square self: this Square object
@param list[Point] corners: corners that define this Square
@rtype: None
>>> s = Square([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 0)])
"""
Shape.__init__(self, corners)
示例10: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, direction='up', *args, **kwargs):
'''Create an oriented triangle.
:Parameters:
`direction` : str
The triangle is oriented relative to its center to this property,
which must be one of the alignment constants `left`, `right`,
`up` or `down`.
'''
self._direction = direction
Shape.__init__(self,*args, **kwargs)
self._update_position()
self._update_shape()
示例11: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, thickness=.4, branches=5, *args, **kwargs):
'''Create a cross.
:Parameters:
`thickness` : int
Thickness of the cross
`branches` : int
Number of branches
'''
self._thickness = thickness
self._branches = branches
Shape.__init__(self, *args, **kwargs)
self._fill_mode = GL_TRIANGLES
self._update_position()
self._update_shape()
示例12: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, corners):
"""
Create RightAngleTriangle self with vertices corners.
Overrides Shape.__init__
Assume corners[0] is the 90 degree angle.
@param RightAngleTriangle self: this RightAngleTriangle object
@param list[Point] corners: corners that define this RightAngleTriangle
@rtype: None
>>> s = RightAngleTriangle([Point(0, 0), Point(1, 0), Point(0, 2)])
"""
Shape.__init__(self, corners)
示例13: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
Shape.__init__(self, color)
self.a = a
self.b = b
self.c = c
self.d = d
self.e = e
self.f = f
t = Transform(2 * a, c, 0, c, 2 * b, 0)
self.center = t.inverse() * Vector(-d, -e)
l1, l0 = quadratic(1, 2 * (-a - b), 4 * a * b - c * c)
v = t.eigv()
axes = [v[0] * ((l0 / 2) ** -0.5), v[1] * ((l1 / 2) ** -0.5)]
self.bound = Vector.union(self.center - axes[0] - axes[1],
self.center - axes[0] + axes[1],
self.center + axes[0] - axes[1],
self.center + axes[0] + axes[1])
示例14: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
Shape.__init__(self, color)
if c*c - 4*a*b >= 0:
raise Exception("Not an ellipse")
self.a = a
self.b = b
self.c = c
self.d = d
self.e = e
self.f = f
self.gradient = Transform(2*a, c, d, c, 2*b, e)
self.center = self.gradient.inverse() * Vector(0, 0)
y1, y2 = quadratic(b-c*c/4*a, e-c*d/2*a, f-d*d/4*a)
x1, x2 = quadratic(a-c*c/4*b, d-c*e/2*b, f-e*e/4*b)
self.bound = AABox.from_vectors(Vector(-(d + c*y1)/2*a, y1),
Vector(-(d + c*y2)/2*a, y2),
Vector(x1, -(e + c*x1)/2*b),
Vector(x2, -(e + c*x2)/2*b))
if not self.contains(self.center):
raise Exception("Internal error, center not inside ellipse")
示例15: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import __init__ [as 别名]
def __init__(self,n,priors=None):
self.n = n
Shape.__init__(self, priors)