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


Python QPainter.HighQualityAntialiasing方法代码示例

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


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

示例1: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def paintEvent(self, _):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        # 背景
        painter.fillRect(self.rect(), Qt.transparent)
        # 进度块
        ratio = (self.value() - self.minimum()) / \
            (self.maximum() - self.minimum())
        width = self.rect().width() * ratio
        if self.isError:
            color = QColor(self._failedColor or CLoadingBar.FailedColor)
        else:
            color = QColor(self._color or CLoadingBar.Color)
        color.setAlpha(self._alpha)
        painter.setBrush(color)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(QRectF(0, 0, width, self.height()), 2, 2) 
开发者ID:PyQt5,项目名称:CustomWidgets,代码行数:21,代码来源:CLoadingBar.py

示例2: draw_block

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def draw_block(self, p, point, w, h):
        if self._qbackground.height() < h * 1.5 or self._qbackground.width() < w * 1.5:
            self.create_pattern(1.5 * np.max([h, w]))

        point.setX((w - self._qbackground.width()) / 2)
        point.setY((h - self._qbackground.height()) / 2)
        p.setRenderHint(QPainter.HighQualityAntialiasing)
        p.drawImage(point, self._qbackground) 
开发者ID:portugueslab,项目名称:stytra,代码行数:10,代码来源:visual.py

示例3: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def paintEvent(self, event):
        super().paintEvent(event)
        if not self.is_revoked:
            return
        rect = event.rect()
        painter = QPainter(self)
        painter.setRenderHints(QPainter.HighQualityAntialiasing)
        pen = QPen(QColor(218, 53, 69))
        pen.setWidth(5)
        pen.setJoinStyle(Qt.RoundJoin)
        pen.setCapStyle(Qt.RoundCap)
        painter.setPen(pen)
        painter.drawEllipse(rect.right() - 53, 3, 50, 53)
        painter.drawLine(rect.right() - 44, 44, rect.right() - 12, 12)
        painter.end() 
开发者ID:Scille,项目名称:parsec-cloud,代码行数:17,代码来源:custom_widgets.py

示例4: paintEvent

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def paintEvent(self, event):
        super(CAvatar, self).paintEvent(event)
        # 画笔
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        # 绘制
        path = QPainterPath()
        diameter = min(self.width(), self.height())
        if self.shape == self.Circle:
            radius = int(diameter / 2)
        elif self.shape == self.Rectangle:
            radius = 4
        halfW = self.width() / 2
        halfH = self.height() / 2
        painter.translate(halfW, halfH)
        path.addRoundedRect(
            QRectF(-halfW, -halfH, diameter, diameter), radius, radius)
        painter.setClipPath(path)
        # 如果是动画效果
        if self.rotateAnimation.state() == QPropertyAnimation.Running:
            painter.rotate(self._angle)  # 旋转
            painter.drawPixmap(
                QPointF(-self.pixmap.width() / 2, -self.pixmap.height() / 2), self.pixmap)
        else:
            painter.drawPixmap(-int(halfW), -int(halfH), self.pixmap)
        # 如果在加载
        if self.loadingTimer.isActive():
            diameter = 2 * self.pradius
            painter.setBrush(
                QColor(45, 140, 240, (1 - self.pradius / 10) * 255))
            painter.setPen(Qt.NoPen)
            painter.drawRoundedRect(
                QRectF(-self.pradius, -self.pradius, diameter, diameter), self.pradius, self.pradius) 
开发者ID:PyQt5,项目名称:CustomWidgets,代码行数:37,代码来源:CAvatar.py

示例5: __init__

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def __init__(self, *args, antialiasing=True, **kwargs):
        super(Label, self).__init__(*args, **kwargs)
        self.Antialiasing = antialiasing
        self.setMaximumSize(200, 200)
        self.setMinimumSize(200, 200)
        self.radius = 100

        #####################核心实现#########################
        self.target = QPixmap(self.size())  # 大小和控件一样
        self.target.fill(Qt.transparent)  # 填充背景为透明

        p = QPixmap("Data/Images/head.jpg").scaled(  # 加载图片并缩放和控件一样大
            200, 200, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)

        painter = QPainter(self.target)
        if self.Antialiasing:
            # 抗锯齿
            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)

        #         painter.setPen(# 测试圆圈
        #             QPen(Qt.red, 5, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        path = QPainterPath()
        path.addRoundedRect(
            0, 0, self.width(), self.height(), self.radius, self.radius)
        # **** 切割为圆形 ****#
        painter.setClipPath(path)
        #         painter.drawPath(path)  # 测试圆圈

        painter.drawPixmap(0, 0, p)
        self.setPixmap(self.target)
        #####################核心实现######################### 
开发者ID:PyQt5,项目名称:PyQt,代码行数:35,代码来源:CircleImage.py

示例6: paint

# 需要导入模块: from PyQt5.QtGui import QPainter [as 别名]
# 或者: from PyQt5.QtGui.QPainter import HighQualityAntialiasing [as 别名]
def paint(self, painter, QStyleOptionGraphicsItem, QWidget_widget=None):
        """

        @type painter: QPainter
        @param QStyleOptionGraphicsItem:
        @param QWidget_widget:
        @return:
        """
        painter.setPen(self.pen())
        x1 = self.line().x1()
        y1 = self.line().y1()
        y2 = self.line().y2()

        x_arrowSize = 10
        y_arrowSize = 0.1 * abs(y2 - y1)
        labelheight = 0.75 * abs(y2 - y1)

        painter.drawLine(QPointF(x1, y1), QPointF(x1, y1 + labelheight / 2))
        painter.drawLine(QPointF(x1, y1), QPointF(x1 + x_arrowSize / 4, y1 + y_arrowSize / 2))
        painter.drawLine(QPointF(x1, y1), QPointF(x1 - x_arrowSize / 4, y1 + y_arrowSize / 2))

        painter.drawLine(QPointF(x1, y2 - labelheight / 2), QPointF(x1, y2))
        painter.drawLine(QPointF(x1, y2), QPointF(x1 + x_arrowSize / 4, y2 - y_arrowSize / 2))
        painter.drawLine(QPointF(x1, y2), QPointF(x1 - x_arrowSize / 4, y2 - y_arrowSize / 2))

        painter.setRenderHint(QPainter.HighQualityAntialiasing)
        fm = painter.fontMetrics()
        pixelsWide = fm.width(self.label)
        pixelsHigh = fm.height()
        scale_factor = (0.2 * labelheight) / fm.height()
        scale_factor = scale_factor if scale_factor > 0 else 0.0000000000000000001
        painter.scale(1, scale_factor)



        # print(y1, y2, pixelsHigh)

        painter.drawText(QPointF(x1 - pixelsWide / 2, (1 / scale_factor) * (y1 + y2) / 2 + pixelsHigh / 4), self.label)
        # painter.drawText(QPointF(x1 - pixelsWide/2, (y1+y2+pixelsHigh)/2), self.label)

        del painter 
开发者ID:jopohl,项目名称:urh,代码行数:43,代码来源:LabeledArrow.py


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