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


Python QPainter.setClipping方法代码示例

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


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

示例1: draw

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setClipping [as 别名]
    def draw(self, endPoint_x, endPoint_y):
        painter = QPainter(self.image)

        painter.setPen(QPen(
            self.myPenColor, self.myPenWidth, QtCore.Qt.SolidLine,
            QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
        painter.setClipping(True)

        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setCompositionMode(QPainter.CompositionMode())

        if self.tools['circle']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            x2 = endPoint_x
            y2 = endPoint_y
            painter.drawEllipse(x1, y1, (x2 - x1), (y2 - y1))

        if self.tools['eraser']:
            painter.setPen(QPen(QtCore.Qt.white, 10, QtCore.Qt.SolidLine))
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)
            self.firstPoint_x = endPoint_x
            self.firstPoint_y = endPoint_y

        if self.tools['pen']:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)
            self.firstPoint_x = endPoint_x
            self.firstPoint_y = endPoint_y

        if self.tools['line'] and self.flag:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)

        if self.tools['rect']:
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            painter.drawRect(self.firstPoint_x, self.firstPoint_y, dx, dy)

        if self.tools['roundRect']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            if x1 > endPoint_x and y1 > endPoint_y:
                painter.drawRoundedRect(
                    endPoint_x, endPoint_y, -dx, -dy, 20, 20, 0)
            else:
                painter.drawRoundedRect(x1, y1, dx, dy, 20., 20.)

        self.modified = True
        self.update()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:57,代码来源:circuitdrawing.py

示例2: drawPreview

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import setClipping [as 别名]
    def drawPreview(self, endPoint_x, endPoint_y):
        painter = QPainter(self.imagePreview)
        painter.setPen(QPen(
            self.myPenColor,
            self.myPenWidth,
            QtCore.Qt.SolidLine,
            QtCore.Qt.RoundCap,
            QtCore.Qt.RoundJoin))
        painter.setClipping(True)

        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.Antialiasing, True)

        painter.setOpacity(0.5)

        if self.tools['circle']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            x2 = endPoint_x
            y2 = endPoint_y
            painter.drawEllipse(x1, y1, (x2 - x1), (y2 - y1))

        if self.tools['line']:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)

        if self.tools['rect']:
            painter.drawRect(
                self.firstPoint_x, self.firstPoint_y,
                endPoint_x - self.firstPoint_x,
                endPoint_y - self.firstPoint_y)

        if self.tools['roundRect']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            if x1 > endPoint_x and y1 > endPoint_y:
                painter.drawRoundedRect(
                    endPoint_x, endPoint_y, -dx, -dy, 20, 20, 0)
            else:
                painter.drawRoundedRect(x1, y1, dx, dy, 20., 20.)

        self.update()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:47,代码来源:circuitdrawing.py


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