本文整理汇总了Python中PyQt5.QtGui.QPolygonF.boundingRect方法的典型用法代码示例。如果您正苦于以下问题:Python QPolygonF.boundingRect方法的具体用法?Python QPolygonF.boundingRect怎么用?Python QPolygonF.boundingRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QPolygonF
的用法示例。
在下文中一共展示了QPolygonF.boundingRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createPreXoverPainterPath
# 需要导入模块: from PyQt5.QtGui import QPolygonF [as 别名]
# 或者: from PyQt5.QtGui.QPolygonF import boundingRect [as 别名]
def _createPreXoverPainterPath( elements: List[List[QPointF]],
end_poly: QPolygonF = None,
is_fwd: bool = True) -> QPainterPath:
path = QPainterPath()
next_pt = None
for element in elements:
start_pt = element[0]
path.moveTo(start_pt)
for next_pt in element[1:]:
path.lineTo(next_pt)
if end_poly is not None:
h = end_poly.boundingRect().height()/2
xoffset = -h if is_fwd else h
w = end_poly.boundingRect().width()
yoffset = w if is_fwd else -w
angle = -90 if is_fwd else 90
T = QTransform()
T.translate(next_pt.x()+xoffset, next_pt.y()+yoffset)
T.rotate(angle)
path.addPolygon(T.map(end_poly))
return path
示例2: image
# 需要导入模块: from PyQt5.QtGui import QPolygonF [as 别名]
# 或者: from PyQt5.QtGui.QPolygonF import boundingRect [as 别名]
def image(cls, **kwargs):
"""
Returns an image suitable for the palette.
:rtype: QPixmap
"""
# INITIALIZATION
pixmap = QPixmap(kwargs['w'], kwargs['h'])
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
polygon = QPolygonF([
QPointF(+27 - 10, -17), # 0
QPointF(-27, -17), # 1
QPointF(-27, +17), # 2
QPointF(+27, +17), # 3
QPointF(+27, -17 + 10), # 4
QPointF(+27 - 10, -17), # 5
])
fold = QPolygonF([
QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y()),
QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y() + 10),
QPointF(polygon[cls.indexRT].x(), polygon[cls.indexRT].y()),
QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y()),
])
# ITEM SHAPE
painter.setPen(QPen(QColor(0, 0, 0), 1.0, Qt.SolidLine))
painter.setBrush(QColor(252, 252, 252))
painter.translate(kwargs['w'] / 2, kwargs['h'] / 2)
painter.drawPolygon(polygon)
painter.drawPolygon(fold)
# TEXT WITHIN THE SHAPE
painter.setFont(Font('Arial', 10, Font.Light))
painter.drawText(polygon.boundingRect(), Qt.AlignCenter, 'value\nrestriction')
return pixmap
示例3: MapObject
# 需要导入模块: from PyQt5.QtGui import QPolygonF [as 别名]
# 或者: from PyQt5.QtGui.QPolygonF import boundingRect [as 别名]
#.........这里部分代码省略.........
# display as the tile image.
#
# \warning The object shape is ignored for tile objects!
##
def setCell(self, cell):
self.mCell = cell
##
# Returns the tile associated with this object.
##
def cell(self):
return self.mCell
##
# Returns the object group this object belongs to.
##
def objectGroup(self):
return self.mObjectGroup
##
# Sets the object group this object belongs to. Should only be called
# from the ObjectGroup class.
##
def setObjectGroup(self, objectGroup):
self.mObjectGroup = objectGroup
##
# Returns the rotation of the object in degrees.
##
def rotation(self):
return self.mRotation
##
# Sets the rotation of the object in degrees.
##
def setRotation(self, rotation):
self.mRotation = rotation
##
# This is somewhat of a workaround for dealing with the ways different objects
# align.
#
# Traditional rectangle objects have top-left alignment.
# Tile objects have bottom-left alignment on orthogonal maps, but
# bottom-center alignment on isometric maps.
#
# Eventually, the object alignment should probably be configurable. For
# backwards compatibility, it will need to be configurable on a per-object
# level.
##
def alignment(self):
if (self.mCell.isEmpty()):
return Alignment.TopLeft
elif (self.mObjectGroup):
map = self.mObjectGroup.map()
if map:
if (map.orientation() == Map.Orientation.Isometric):
return Alignment.Bottom
return Alignment.BottomLeft
def isVisible(self):
return self.mVisible
def setVisible(self, visible):
self.mVisible = visible
##
# Flip this object in the given \a direction. This doesn't change the size
# of the object.
##
def flip(self, direction):
if (not self.mCell.isEmpty()):
if (direction == FlipDirection.FlipHorizontally):
self.mCell.flippedHorizontally = not self.mCell.flippedHorizontally
elif (direction == FlipDirection.FlipVertically):
self.mCell.flippedVertically = not self.mCell.flippedVertically
if (not self.mPolygon.isEmpty()):
center2 = self.mPolygon.boundingRect().center() * 2
if (direction == FlipDirection.FlipHorizontally):
for i in range(self.mPolygon.size()):
# oh, QPointF mPolygon returned is a copy of internal object
self.mPolygon[i] = QPointF(center2.x() - self.mPolygon[i].x(), self.mPolygon[i].y())
elif (direction == FlipDirection.FlipVertically):
for i in range(self.mPolygon.size()):
self.mPolygon[i] = QPointF(self.mPolygon[i].x(), center2.y() - self.mPolygon[i].y())
##
# Returns a duplicate of this object. The caller is responsible for the
# ownership of this newly created object.
##
def clone(self):
o = MapObject(self.mName, self.mType, self.mPos, self.mSize)
o.setProperties(self.properties())
o.setPolygon(self.mPolygon)
o.setShape(self.mShape)
o.setCell(self.mCell)
o.setRotation(self.mRotation)
return o
示例4: setRect
# 需要导入模块: from PyQt5.QtGui import QPolygonF [as 别名]
# 或者: from PyQt5.QtGui.QPolygonF import boundingRect [as 别名]
def setRect(self):
polygon = QPolygonF(self.points)
rect = polygon.boundingRect()
self._rect = rect
self._boundingRect = rect