base.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:lolLoadingInfo 作者: fab0l1n 项目源码 文件源码
def modify(self, img: QtGui.QPixmap, mult: float=1.0, rounding: int=0, cut: int=5):

        if img.width() == 0 or img.height() == 0:
            log.info("FATAL ERROR: IMG NOT LOADED")
            return img

        img = QtGui.QPixmap(img)
        h = img.height()
        w = img.width()
        color = QtGui.QColor(0, 0, 0, 0)  # (r,g,b, density)
        pix = QtGui.QPixmap(QtCore.QSize(w, h))
        pix.fill(color)

        if not rounding > 0:
            cut = 0
        rect = QtCore.QRectF(-1 + cut, -1 + cut, 2 + w - cut * 2, 2 + h - cut * 2)
        painter = QtGui.QPainter()
        painter.begin(pix)
        painter.setRenderHints(QtGui.QPainter.Antialiasing, True)
        path = QtGui.QPainterPath()
        path.addRoundedRect(rect, rounding, rounding)
        painter.drawPath(path)
        brush = QtGui.QBrush()
        brush.setTexture(img)
        painter.fillPath(path, brush)
        painter.end()
        return pix.scaledToWidth(pix.width() * mult)
        # credits to:   http://python.6.x6.nabble.com/Rounded-corners-td4716825.html
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号