本文整理汇总了Python中PyQt5.QtCore.QLineF.y1方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.y1方法的具体用法?Python QLineF.y1怎么用?Python QLineF.y1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.y1方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _drawGuidelines
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import y1 [as 别名]
def _drawGuidelines(painter, glyph, scale, rect, guidelines, drawLines=True,
drawText=True, drawSelection=True, color=None):
if not (drawLines or drawText):
return
xMin, yMin, width, height = rect
xMax = xMin + width
yMax = yMin + height
fontSize = painter.font().pointSize()
for line in guidelines:
color_ = color
if color_ is None:
if line.color:
color_ = colorToQColor(line.color)
else:
color_ = defaultColor("glyphGuideline")
painter.save()
painter.setPen(color)
line1 = None
if None not in (line.x, line.y):
if line.angle is not None:
# make an infinite line that intersects *(line.x, line.y)*
# 1. make horizontal line from *(line.x, line.y)* of length
# *diagonal*
diagonal = math.sqrt(width**2 + height**2)
line1 = QLineF(line.x, line.y, line.x + diagonal, line.y)
# 2. set the angle
# defcon guidelines are clockwise
line1.setAngle(line.angle)
# 3. reverse the line and set length to 2 * *diagonal*
line1.setPoints(line1.p2(), line1.p1())
line1.setLength(2 * diagonal)
else:
line1 = QLineF(xMin, line.y, xMax, line.y)
textX = 0
textY = 0
if drawLines:
if line1 is not None:
# line
drawLine(
painter, line1.x1(), line1.y1(), line1.x2(), line1.y2())
# point
x, y = line.x, line.y
smoothWidth = 8 * scale
smoothHalf = smoothWidth / 2.0
painter.save()
pointPath = QPainterPath()
x -= smoothHalf
y -= smoothHalf
pointPath.addEllipse(x, y, smoothWidth, smoothWidth)
pen = QPen(color_)
pen.setWidthF(1 * scale)
painter.setPen(pen)
if drawSelection and line.selected:
painter.fillPath(pointPath, color_)
painter.drawPath(pointPath)
painter.restore()
else:
if line.y is not None:
drawLine(painter, xMin, line.y, xMax, line.y)
elif line.x is not None:
drawLine(painter, line.x, yMin, line.x, yMax)
if drawText and line.name:
if line1 is not None:
textX = line.x
textY = line.y - 6 * scale
xAlign = "center"
else:
if line.y is not None:
textX = glyph.width + 6 * scale
textY = line.y - (fontSize / 3.5) * scale
elif line.x is not None:
textX = line.x + 6 * scale
textY = 0
xAlign = "left"
drawTextAtPoint(
painter, line.name, textX, textY, scale, xAlign=xAlign)
painter.restore()