当前位置: 首页>>代码示例>>Python>>正文


Python QPainterPath.moveTo方法代码示例

本文整理汇总了Python中PyQt5.Qt.QPainterPath.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.moveTo方法的具体用法?Python QPainterPath.moveTo怎么用?Python QPainterPath.moveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.Qt.QPainterPath的用法示例。


在下文中一共展示了QPainterPath.moveTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_line

# 需要导入模块: from PyQt5.Qt import QPainterPath [as 别名]
# 或者: from PyQt5.Qt.QPainterPath import moveTo [as 别名]
 def create_line(ly, ry, right_to_left=False):
     ' Create path that represents upper or lower line of change marker '
     line = QPainterPath()
     if not right_to_left:
         line.moveTo(0, ly)
         line.cubicTo(C, ly, w - C, ry, w, ry)
     else:
         line.moveTo(w, ry)
         line.cubicTo(w - C, ry, C, ly, 0, ly)
     return line
开发者ID:AtulKumar2,项目名称:calibre,代码行数:12,代码来源:view.py

示例2: shape

# 需要导入模块: from PyQt5.Qt import QPainterPath [as 别名]
# 或者: from PyQt5.Qt.QPainterPath import moveTo [as 别名]
    def shape(self):
        '''Defines the selection shape of the item.'''
        stroker = QPainterPathStroker()

        # Tolerance on click to update if needed
        stroker.setWidth(12)

        path = QPainterPath()
        path.moveTo(self.line().p1())
        path.lineTo(self.line().p2())

        return stroker.createStroke(path)
开发者ID:pydoted,项目名称:dotEd,代码行数:14,代码来源:GraphicsLineEdge.py

示例3: _draw_column_data

# 需要导入模块: from PyQt5.Qt import QPainterPath [as 别名]
# 或者: from PyQt5.Qt.QPainterPath import moveTo [as 别名]
    def _draw_column_data(self, painter, color, xcol,
                        ycol, xmin, xmax, ymin, ymax):

        painter.setPen( QPen(QColor(color), 2,
                        Qt.SolidLine, Qt.RoundCap))

        path = QPainterPath()

        row = self.data.rows[0]
        x, y = self._xy_from_data(row[xcol], row[ycol],
                                xmin, xmax, ymin, ymax)
        path.moveTo(x, y)

        for row in self.data.rows[1:]:
            x, y = self._xy_from_data(row[xcol], row[ycol],
                                    xmin, xmax, ymin, ymax)
            path.lineTo(x, y)
            painter.drawPath(path)
开发者ID:maxdesp,项目名称:PyQtCharts,代码行数:20,代码来源:qcharts.py

示例4: paintEvent

# 需要导入模块: from PyQt5.Qt import QPainterPath [as 别名]
# 或者: from PyQt5.Qt.QPainterPath import moveTo [as 别名]
    def paintEvent(self, event):
        QSplitterHandle.paintEvent(self, event)
        left, right = self.parent().left, self.parent().right
        painter = QPainter(self)
        painter.setClipRect(event.rect())
        w = self.width()
        h = self.height()
        painter.setRenderHints(QPainter.Antialiasing, True)

        C = 16  # Curve factor.

        def create_line(ly, ry, right_to_left=False):
            ' Create path that represents upper or lower line of change marker '
            line = QPainterPath()
            if not right_to_left:
                line.moveTo(0, ly)
                line.cubicTo(C, ly, w - C, ry, w, ry)
            else:
                line.moveTo(w, ry)
                line.cubicTo(w - C, ry, C, ly, 0, ly)
            return line

        ldoc, rdoc = left.document(), right.document()
        lorigin, rorigin = left.contentOffset(), right.contentOffset()
        lfv, rfv = left.firstVisibleBlock().blockNumber(), right.firstVisibleBlock().blockNumber()
        lines = []

        for (ltop, lbot, kind), (rtop, rbot, kind) in zip(left.changes, right.changes):
            if lbot < lfv and rbot < rfv:
                continue
            ly_top = left.blockBoundingGeometry(ldoc.findBlockByNumber(ltop)).translated(lorigin).y()
            ly_bot = left.blockBoundingGeometry(ldoc.findBlockByNumber(lbot)).translated(lorigin).y()
            ry_top = right.blockBoundingGeometry(rdoc.findBlockByNumber(rtop)).translated(rorigin).y()
            ry_bot = right.blockBoundingGeometry(rdoc.findBlockByNumber(rbot)).translated(rorigin).y()
            if max(ly_top, ly_bot, ry_top, ry_bot) < 0:
                continue
            if min(ly_top, ly_bot, ry_top, ry_bot) > h:
                break

            upper_line = create_line(ly_top, ry_top)
            lower_line = create_line(ly_bot, ry_bot, True)

            region = QPainterPath()
            region.moveTo(0, ly_top)
            region.connectPath(upper_line)
            region.lineTo(w, ry_bot)
            region.connectPath(lower_line)
            region.closeSubpath()

            painter.fillPath(region, left.diff_backgrounds[kind])
            for path, aa in zip((upper_line, lower_line), (ly_top != ry_top, ly_bot != ry_bot)):
                lines.append((kind, path, aa))

        for kind, path, aa in sorted(lines, key=lambda x:{'replace':0}.get(x[0], 1)):
            painter.setPen(left.diff_foregrounds[kind])
            painter.setRenderHints(QPainter.Antialiasing, aa)
            painter.drawPath(path)

        painter.setFont(left.heading_font)
        for (lnum, text), (rnum, text) in zip(left.headers, right.headers):
            ltop, lbot, rtop, rbot = lnum, lnum + 3, rnum, rnum + 3
            if lbot < lfv and rbot < rfv:
                continue
            ly_top = left.blockBoundingGeometry(ldoc.findBlockByNumber(ltop)).translated(lorigin).y()
            ly_bot = left.blockBoundingGeometry(ldoc.findBlockByNumber(lbot)).translated(lorigin).y()
            ry_top = right.blockBoundingGeometry(rdoc.findBlockByNumber(rtop)).translated(rorigin).y()
            ry_bot = right.blockBoundingGeometry(rdoc.findBlockByNumber(rbot)).translated(rorigin).y()
            if max(ly_top, ly_bot, ry_top, ry_bot) < 0:
                continue
            if min(ly_top, ly_bot, ry_top, ry_bot) > h:
                break
            ly = painter.boundingRect(3, ly_top, left.width(), ly_bot - ly_top - 5, Qt.TextSingleLine, text).bottom() + 3
            ry = painter.boundingRect(3, ry_top, right.width(), ry_bot - ry_top - 5, Qt.TextSingleLine, text).bottom() + 3
            line = create_line(ly, ry)
            painter.setPen(QPen(left.palette().text(), 2))
            painter.setRenderHints(QPainter.Antialiasing, ly != ry)
            painter.drawPath(line)

        painter.end()
        # Paint the splitter without the change lines if the mouse is over the
        # splitter
        if getattr(self, 'hover', False):
            QSplitterHandle.paintEvent(self, event)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:85,代码来源:view.py

示例5: svg_path_to_painter_path

# 需要导入模块: from PyQt5.Qt import QPainterPath [as 别名]
# 或者: from PyQt5.Qt.QPainterPath import moveTo [as 别名]
def svg_path_to_painter_path(d):
    '''
    Convert a tiny SVG 1.2 path into a QPainterPath.

    :param d: The value of the d attribute of an SVG <path> tag
    '''
    from PyQt5.Qt import QPainterPath
    cmd = last_cmd = b''
    path = QPainterPath()
    moveto_abs, moveto_rel = b'Mm'
    closepath1, closepath2 = b'Zz'
    lineto_abs, lineto_rel = b'Ll'
    hline_abs, hline_rel = b'Hh'
    vline_abs, vline_rel = b'Vv'
    curveto_abs, curveto_rel = b'Cc'
    smoothcurveto_abs, smoothcurveto_rel = b'Ss'
    quadcurveto_abs, quadcurveto_rel = b'Qq'
    smoothquadcurveto_abs, smoothquadcurveto_rel = b'Tt'

    # Store the last parsed values
    # x/y = end position
    # x1/y1 and x2/y2 = bezier control points
    x = y = x1 = y1 = x2 = y2 = 0

    data = d.replace(b',', b' ').replace(b'\n', b' ')
    if isinstance(data, type('')):
        data = data.encode('ascii')
    end = len(data)
    data = ReadOnlyFileBuffer(data)

    def parse_float():
        chars = []
        while data.tell() < end:
            c = data.read(1)
            if c == b' ' and not chars:
                continue
            if c == b'-' or b'0' <= c[0] <= b'9' or c == b'.':
                chars.append(c[0])
            else:
                break
        if not chars:
            raise ValueError('Premature end of input while expecting a number')
        return float(b''.join(chars))

    def parse_floats(num, x_offset=0, y_offset=0):
        for i in xrange(num):
            val = parse_float()
            yield val + (x_offset if i % 2 == 0 else y_offset)

    repeated_command = None

    while data.tell() < end:
        last_cmd = cmd
        cmd = data.read(1) if repeated_command is None else repeated_command
        repeated_command = None

        if cmd == b' ':
            continue
        elif cmd == moveto_abs:
            x, y = parse_float(), parse_float()
            path.moveTo(x, y)
        elif cmd == moveto_rel:
            x += parse_float()
            y += parse_float()
            path.moveTo(x, y)
        elif cmd == closepath1 or cmd == closepath2:
            path.closeSubpath()
        elif cmd == lineto_abs:
            x, y = parse_floats(2)
            path.lineTo(x, y)
        elif cmd == lineto_rel:
            x += parse_float()
            y += parse_float()
            path.lineTo(x, y)
        elif cmd == hline_abs:
            x = parse_float()
            path.lineTo(x, y)
        elif cmd == hline_rel:
            x += parse_float()
            path.lineTo(x, y)
        elif cmd == vline_abs:
            y = parse_float()
            path.lineTo(x, y)
        elif cmd == vline_rel:
            y += parse_float()
            path.lineTo(x, y)
        elif cmd == curveto_abs:
            x1, y1, x2, y2, x, y = parse_floats(6)
            path.cubicTo(x1, y1, x2, y2, x, y)
        elif cmd == curveto_rel:
            x1, y1, x2, y2, x, y = parse_floats(6, x, y)
            path.cubicTo(x1, y1, x2, y2, x, y)
        elif cmd == smoothcurveto_abs:
            if last_cmd == curveto_abs or last_cmd == curveto_rel or last_cmd == smoothcurveto_abs or last_cmd == smoothcurveto_rel:
                x1 = 2 * x - x2
                y1 = 2 * y - y2
            else:
                x1, y1 = x, y
            x2, y2, x, y = parse_floats(4)
            path.cubicTo(x1, y1, x2, y2, x, y)
#.........这里部分代码省略.........
开发者ID:Coi-l,项目名称:calibre,代码行数:103,代码来源:speedups.py


注:本文中的PyQt5.Qt.QPainterPath.moveTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。