Beispiel #1
0
    def draw_NI_extended_background(painter, c, w, h, bounding_rect,
                                    title_rect):
        """
        :param painter: painter from paint event
        :param c: NodeInstance's theme color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        :param title_rect: NI's title label's bounding rect
        """

        background_color = QColor('#212429')
        header_color = c

        rel_header_height = NIPainter.get_header_rect(w, h,
                                                      title_rect).height() / h
        gradient = QLinearGradient(bounding_rect.topLeft(),
                                   bounding_rect.bottomLeft())
        gradient.setColorAt(0, header_color)
        gradient.setColorAt(rel_header_height, header_color)
        gradient.setColorAt(rel_header_height + 0.0001, background_color)
        gradient.setColorAt(1, background_color)

        painter.setBrush(gradient)
        painter.setPen(Qt.NoPen)  #QPen(c.darker()))
        painter.drawRoundedRect(bounding_rect, 9, 9)
Beispiel #2
0
    def brushChanged(self):
        style = Qt.BrushStyle(self.brushStyleComboBox.itemData(
                self.brushStyleComboBox.currentIndex(), IdRole))

        if style == Qt.LinearGradientPattern:
            linearGradient = QLinearGradient(0, 0, 100, 100)
            linearGradient.setColorAt(0.0, Qt.white)
            linearGradient.setColorAt(0.2, Qt.green)
            linearGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(linearGradient))
        elif style == Qt.RadialGradientPattern:
            radialGradient = QRadialGradient(50, 50, 50, 70, 70)
            radialGradient.setColorAt(0.0, Qt.white)
            radialGradient.setColorAt(0.2, Qt.green)
            radialGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(radialGradient))
        elif style == Qt.ConicalGradientPattern:
            conicalGradient = QConicalGradient(50, 50, 150)
            conicalGradient.setColorAt(0.0, Qt.white)
            conicalGradient.setColorAt(0.2, Qt.green)
            conicalGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(conicalGradient))
        elif style == Qt.TexturePattern:
            self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png')))
        else:
            self.renderArea.setBrush(QBrush(Qt.green, style))
    def drawBg(self, painter: QPainter) -> None:
        painter.save()

        # 设置边框颜色及宽度
        pen: QPen = QPen()
        pen.setColor(self.__borderColor)
        pen.setWidthF(self.__borderWidth)
        painter.setPen(pen)

        # 绘制区域要减去边框宽度
        rect: QRect = QRect()
        rect.setX(self.__borderWidth)
        rect.setY(self.__borderWidth)
        rect.setWidth(self.width() - self.__borderWidth * 2)
        rect.setHeight(self.height() - self.__borderWidth * 2)

        # 如果背景图片存在则显示背景图片,否则显示背景色
        if not self.__bgImage.isNull():
            # 等比例缩放绘制
            img: QPixmap = self.__bgImage.scaled(rect.width(), rect.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
            painter.drawPixmap((self.rect().width() - img.width()) / 2, (self.rect().height() - img.height()) / 2, img)
        else:
            if self.__colorMode == ColorButton.ColorMode.ColorMode_Normal:
                if self.__isPressed:
                    painter.setBrush(QBrush(self.__pressedColor))
                else:
                    painter.setBrush(QBrush(self.__normalColor))
            elif self.__colorMode == ColorButton.ColorMode.ColorMode_Replace:
                gradient: QLinearGradient = QLinearGradient(QPoint(0, 0), QPoint(0, self.height()))

                if self.__isPressed:
                    gradient.setColorAt(0.0, self.__pressedColor)
                    gradient.setColorAt(0.49, self.__pressedColor)
                    gradient.setColorAt(0.50, self.__normalColor)
                    gradient.setColorAt(1.0, self.__normalColor)
                else:
                    gradient.setColorAt(0.0, self.__normalColor)
                    gradient.setColorAt(0.49, self.__normalColor)
                    gradient.setColorAt(0.50, self.__pressedColor)
                    gradient.setColorAt(1.0, self.__pressedColor)

                painter.setBrush(gradient)
            elif self.__colorMode == ColorButton.ColorMode.ColorMode_Shade:
                gradient: QLinearGradient = QLinearGradient(QPoint(0, 0), QPoint(0, self.height()))

                if self.__isPressed:
                    gradient.setColorAt(0.0, self.__pressedColor)
                    gradient.setColorAt(1.0, self.__normalColor)
                else:
                    gradient.setColorAt(0.0, self.__normalColor)
                    gradient.setColorAt(1.0, self.__pressedColor)

                painter.setBrush(gradient)

            painter.drawRoundedRect(rect, self.__borderRadius, self.__borderRadius)

        painter.restore()
    def draw_tron_extended_background(self, painter, c, w, h, bounding_rect):
        """
        :param painter: painter from paint event
        :param c: NodeInstance's theme color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        """

        # main rect
        background_color = QColor('#212224')
        painter.setBrush(background_color)
        pen = QPen(c)
        pen.setWidth(2)
        painter.setPen(pen)
        body_path = self.get_extended_body_path_TRON_DESIGN(10, w, h)
        painter.drawPath(body_path)

        header_gradient = QLinearGradient(
            self.get_header_rect(w, h).topRight(),
            self.get_header_rect(w, h).bottomLeft())
        header_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
                                             255))
        header_gradient.setColorAt(0.5,
                                   QColor(c.red(), c.green(), c.blue(), 100))
        header_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 0))
        painter.setBrush(header_gradient)
        header_path = self.get_extended_header_path_TRON_DESIGN(10, w, h)
        painter.drawPath(header_path)
Beispiel #5
0
    def draw_NI_extended_background(painter, c, w, h, bounding_rect,
                                    title_rect):
        """
        :param painter: painter from paint event
        :param c: NodeInstance's theme color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        :param title_rect: NI's title label's bounding rect
        """

        background_color = QColor('#212224')
        painter.setBrush(background_color)
        pen = QPen(c)
        pen.setWidth(2)
        painter.setPen(pen)
        body_path = NIPainter_DarkTron.get_extended_body_path(w, h)
        painter.drawPath(body_path)

        header_gradient = QLinearGradient(
            NIPainter_DarkTron.get_header_rect(w, h, title_rect).topRight(),
            NIPainter_DarkTron.get_header_rect(w, h, title_rect).bottomLeft())
        header_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
                                             255))
        header_gradient.setColorAt(0.5,
                                   QColor(c.red(), c.green(), c.blue(), 100))
        header_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 0))
        painter.setBrush(header_gradient)
        header_path = NIPainter_DarkTron.get_extended_header_path(
            w, h, title_rect)
        painter.drawPath(header_path)
    def __init__(self, parent=None):
        super().__init__(parent)
        self.gradient = QLinearGradient(0, 0, 0, self.height())
        self.labels = {}
        self.margin = 10
        self._barThickness = 20
        self._labelMargin = 2

        self._maxLabelWidth = None
        self._maxLabelHeight = None

        self._orientation = 'Vertical'
        self.setStyleSheet("background-color: rgba(255,0,255,0)")
        self.setAttribute(Qt.WA_NoSystemBackground)
Beispiel #7
0
    def drawGradient(self, qp):
        gradient = QLinearGradient(QPointF(200,15), QPointF(600,60))
        gradient.setColorAt(0,Qt.blue)
        gradient.setColorAt(0.25,Qt.cyan)
        gradient.setColorAt(0.5,Qt.green)
        gradient.setColorAt(0.75,Qt.yellow)
        gradient.setColorAt(1,Qt.red)
        qp.setBrush(gradient)
        qp.drawRect(200, 15, 600, 60)

        qp.setFont(QFont('Arial', 8))
        qp.setBrush(Qt.black)
        qp.drawText(200, 0, 205, 15, Qt.AlignLeft, "0")
        qp.drawText(395, 0, 405, 15, Qt.AlignLeft, "0.5")
        qp.drawText(595, 0, 600, 15, Qt.AlignLeft, "1")
    def drawOverlay(self, painter: QPainter) -> None:
        if not self.__showOverlay: return

        radius: int = 80
        painter.save()
        painter.setPen(Qt.NoPen)

        smallCircle: QPainterPath = QPainterPath()
        bigCircle: QPainterPath = QPainterPath()
        radius -= 1
        smallCircle.addEllipse(-radius, -radius, radius * 2, radius * 2)
        radius *= 2
        bigCircle.addEllipse(-radius, -radius + 140, radius * 2, radius * 2)

        # 高光的形状为小圆扣掉大圆的部分
        highlight: QPainterPath = smallCircle - bigCircle

        linearGradient: QLinearGradient = QLinearGradient(0, -radius / 2, 0, 0)
        self.__overlayColor.setAlpha(100)
        linearGradient.setColorAt(0.0, self.__overlayColor)
        self.__overlayColor.setAlpha(30)
        linearGradient.setColorAt(1.0, self.__overlayColor)
        painter.setBrush(linearGradient)
        painter.rotate(-20)
        painter.drawPath(highlight)

        painter.restore()
Beispiel #9
0
    def showEvent(self, event: QShowEvent = None) -> None:
        # 首次显示记住当前背景截图,用于获取颜色值
        self.__bgPix = QPixmap(self.width(), self.height())
        self.__bgPix.fill(Qt.transparent)
        painter: QPainter = QPainter()
        painter.begin(self.__bgPix)

        linearGradient: QLinearGradient = QLinearGradient()

        if self.__hsbMode:
            # 起始坐标和结束坐标换个位置可改变颜色顺序
            linearGradient.setStart(
                QPoint(self.__bgRect.x(), self.__bgRect.height()))
            linearGradient.setFinalStop(
                QPoint(self.__bgRect.x(), self.__bgRect.y()))

            # 由下往上,饱和度百分值由0增加到1.0
            for i in [i * 0.0625 for i in range(17)]:
                linearGradient.setColorAt(i, QColor.fromHsvF(i, 1, 1, 1))
        else:
            linearGradient.setStart(QPointF(0, 0))
            linearGradient.setFinalStop(QPointF(0, self.height()))
            linearGradient.setColorAt(0.0, self.__topColor)
            linearGradient.setColorAt(1.0, self.__bottomColor)

        painter.setPen(Qt.NoPen)
        painter.setBrush(linearGradient)

        rect: QRect = QRect(self.__borderWidth // 2, self.__borderWidth // 2,
                            self.width() - self.__borderWidth,
                            self.height() - self.__borderWidth)
        painter.drawRect(rect)
        painter.end()

        self.initColor()
    def showEvent(self, event: QShowEvent = None) -> None:
        width: int = self.width()
        height: int = self.height()

        # 首次显示记住当前背景截图,用于获取颜色值
        self.__bgPix = QPixmap(width, height)
        self.__bgPix.fill(Qt.transparent)
        painter: QPainter = QPainter()
        painter.begin(self.__bgPix)

        colorStart: QColor = QColor()
        colorCenter: QColor = QColor()
        colorEnd: QColor = QColor()
        for i in range(width):
            colorStart.setHslF(i / width, 1, 0)
            colorCenter.setHslF(i / width, 1, 0.5)
            colorEnd.setHslF(i / width, 1, 1)

            linearGradient: QLinearGradient = QLinearGradient()
            linearGradient.setStart(QPointF(i, -height))
            linearGradient.setFinalStop(QPointF(i, height))
            linearGradient.setColorAt(0.0, colorStart)
            linearGradient.setColorAt(0.5, colorCenter)
            linearGradient.setColorAt(1.0, colorEnd)

            painter.setPen(QPen(linearGradient, 1))
            painter.drawLine(QPointF(i, 0), QPointF(i, height))

        painter.end()
        def initForm(self) -> None:
            brush: QLinearGradient = QLinearGradient(0, 0,
                                                     self.progressTip1.width(),
                                                     0)

            brush.setColorAt(0, "#49AFFB")
            brush.setColorAt(1, "#5D51FF")
            self.progressTip1.valueBrush = QBrush(brush)

            brush.setColorAt(0, "#32B9CF")
            brush.setColorAt(1, "#C13256")
            self.progressTip2.valueBrush = QBrush(brush)

            brush.setColorAt(0, "#C13256")
            brush.setColorAt(1, "#32B9CF")
            self.progressTip3.valueBrush = QBrush(brush)

            self.progressTip3.radius = 7
            self.progressTip4.radius = 7
            self.progressTip3.valueColor = QColor("#FA358A")
            self.progressTip4.valueColor = QColor("#2EA3EF")
            self.progressTip3.tipColor = QColor("#FA358A")
            self.progressTip4.tipColor = QColor("#2EA3EF")

            self.horizontalSlider.valueChanged.connect(
                self.progressTip1.setValue)
            self.horizontalSlider.valueChanged.connect(
                self.progressTip2.setValue)
            self.horizontalSlider.valueChanged.connect(
                self.progressTip3.setValue)
            self.horizontalSlider.valueChanged.connect(
                self.progressTip4.setValue)
            self.horizontalSlider.setValue(88)
            self.horizontalSlider.setMaximum(100)
 def drawBg(self, painter: QPainter) -> None:
     painter.save()
     painter.setPen(Qt.NoPen)
     bgGradient: QLinearGradient = QLinearGradient(QPoint(0, 0), QPoint(0, self.height()))
     bgGradient.setColorAt(0.0, self.__bgColorStart)
     bgGradient.setColorAt(1.0, self.__bgColorEnd)
     painter.setBrush(bgGradient)
     painter.drawRect(self.rect())
     painter.restore()
Beispiel #13
0
    def __init__(self, q, parent=None, leftText='ON', rightText='OFF'):
        QObject.__init__(self, parent=parent)
        self.leftText = leftText
        self.rightText = rightText
        self.mPointer = q
        self.mPosition = 0.0
        self.mGradient = QLinearGradient()
        self.mGradient.setSpread(QGradient.PadSpread)

        self.animation = QPropertyAnimation(self)
        self.animation.setTargetObject(self)
        self.animation.setPropertyName(b'position')
        self.animation.setStartValue(0.0)
        self.animation.setEndValue(1.0)
        self.animation.setDuration(200)
        self.animation.setEasingCurve(QEasingCurve.InOutExpo)

        self.animation.finished.connect(self.mPointer.update)
Beispiel #14
0
    def drawCircle(self, painter: QPainter) -> None:
        radius: int = self.__radiusCircle
        painter.save()
        painter.setPen(Qt.NoPen)
        bgGradient: QLinearGradient = QLinearGradient(0, -radius, 0, radius)
        bgGradient.setColorAt(0.0, self.__circleColorStart)
        bgGradient.setColorAt(1.0, self.__circleColorEnd)
        painter.setBrush(bgGradient)

        painter.drawEllipse(-radius, -radius, radius * 2, radius * 2)
        painter.restore()
 def drawBorderIn(self, painter: QPainter) -> None:
     radius: int = 90
     painter.save()
     painter.setPen(Qt.NoPen)
     borderGradient: QLinearGradient = QLinearGradient(
         0, -radius, 0, radius)
     borderGradient.setColorAt(0, self.__borderInColorStart)
     borderGradient.setColorAt(1, self.__borderInColorEnd)
     painter.setBrush(borderGradient)
     painter.drawEllipse(-radius, -radius, radius * 2, radius * 2)
     painter.restore()
Beispiel #16
0
    def __init__(self,
                 viewer: ColorTransferFunctionViewer,
                 begin_point: ColorTransferFunctionPoint,
                 end_point: ColorTransferFunctionPoint,
                 parent: QGraphicsItem = None):
        super().__init__(parent)

        self.viewer = viewer
        self._begin_point = None
        self._end_point = None
        self.chart = self.viewer.chart

        self.brush_gradient = QLinearGradient()
        self.brush_gradient.setStart(QPointF(0, 0))
        self.brush_gradient.setFinalStop(QPointF(1, 0))
        self.brush_gradient.setCoordinateMode(QGradient.ObjectMode)

        self.setPen(QColor('#404040'))

        self.begin_point = begin_point
        self.end_point = end_point
Beispiel #17
0
    def paintEngine(self):
        myGradient = QLinearGradient()
        myPen = QPen()
        myPolygon = QPolygonF()

        myPath = QPainterPath()
        myPath.addPolygon(myPolygon)

        painter = QPainter()
        painter.setBrush(myGradient)
        painter.setPen(myPen)
        painter.drawPath(myPath)
Beispiel #18
0
    def draw_dark_extended_background(self, painter):
        c = self.parent_node.color

        # main rect
        body_gradient = QRadialGradient(self.boundingRect().topLeft(),
                                        pythagoras(self.height, self.width))
        body_gradient.setColorAt(
            0,
            QColor(c.red() / 10 + 100,
                   c.green() / 10 + 100,
                   c.blue() / 10 + 100, 200))
        body_gradient.setColorAt(
            1,
            QColor(c.red() / 10 + 100,
                   c.green() / 10 + 100,
                   c.blue() / 10 + 100, 0))

        painter.setBrush(body_gradient)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(self.boundingRect(), 12, 12)

        header_gradient = QLinearGradient(self.get_header_rect().topRight(),
                                          self.get_header_rect().bottomLeft())
        header_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
                                             255))
        header_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 0))
        painter.setBrush(header_gradient)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(self.get_header_rect(), 12, 12)
Beispiel #19
0
    def draw_NI_minimalistic(painter, c, w, h, bounding_rect):
        """
        :param painter: painter from paint event
        :param c: color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        """

        path = QPainterPath()
        path.moveTo(-w / 2, 0)

        path.cubicTo(-w / 2, -h / 2, -w / 2, -h / 2, 0, -h / 2)
        path.cubicTo(+w / 2, -h / 2, +w / 2, -h / 2, +w / 2, 0)
        path.cubicTo(+w / 2, +h / 2, +w / 2, +h / 2, 0, +h / 2)
        path.cubicTo(-w / 2, +h / 2, -w / 2, +h / 2, -w / 2, 0)
        path.closeSubpath()

        body_gradient = QLinearGradient(bounding_rect.bottomLeft(),
                                        bounding_rect.topRight())
        body_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(), 150))
        body_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 80))

        painter.setBrush(body_gradient)
        painter.setPen(QPen(QColor(30, 43, 48)))

        painter.drawPath(path)
    def brushChanged(self):
        style = Qt.BrushStyle(
            self.brushStyleComboBox.itemData(
                self.brushStyleComboBox.currentIndex(), IdRole))

        if style == Qt.LinearGradientPattern:
            linearGradient = QLinearGradient(0, 0, 100, 100)
            linearGradient.setColorAt(0.0, Qt.white)
            linearGradient.setColorAt(0.2, Qt.green)
            linearGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(linearGradient))
        elif style == Qt.RadialGradientPattern:
            radialGradient = QRadialGradient(50, 50, 50, 70, 70)
            radialGradient.setColorAt(0.0, Qt.white)
            radialGradient.setColorAt(0.2, Qt.green)
            radialGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(radialGradient))
        elif style == Qt.ConicalGradientPattern:
            conicalGradient = QConicalGradient(50, 50, 150)
            conicalGradient.setColorAt(0.0, Qt.white)
            conicalGradient.setColorAt(0.2, Qt.green)
            conicalGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(conicalGradient))
        elif style == Qt.TexturePattern:
            self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png')))
        else:
            self.renderArea.setBrush(QBrush(Qt.green, style))
Beispiel #21
0
    def _updateSignalColor(self, signalName, newColor):
        chIter = QTreeWidgetItemIterator(self.chSelector,
                                        QTreeWidgetItemIterator.Checked)
        while chIter.value():
            if chIter.value().text(0) == signalName:
                sColor = QColor(newColor)
                sColor.setAlpha(100)
                chIter.value().setBackgroundColor(0, sColor)
            chIter += 1

        sIter = QTreeWidgetItemIterator(self.sSelector)
        while sIter.value():
            if sIter.value().text(0) == signalName:
                sColor = QColor(newColor)
                sColor.setAlpha(100)
                sGradient = QLinearGradient(0, 0, 100, 10)
                sGradient.setColorAt(0, sColor)
                sGradient.setColorAt(1, Qt.white)
                sBrush = QBrush(sGradient)
                sBrush.setStyle(Qt.LinearGradientPattern)
                sBrush.setColor(sColor)
                sIter.value().setBackground(0, sBrush)
                if sIter.value() is self.curSelect:
                    self.prevBackGround = sIter.value().background(0)
            sIter += 1

        self.changeCurrentSelect(self.curSelect)
Beispiel #22
0
    def draw_dark_minimalistic(self, painter):
        path = QPainterPath()
        path.moveTo(-self.width / 2, 0)

        path.cubicTo(-self.width / 2, -self.height / 2,
                     -self.width / 2, -self.height / 2,
                     0, -self.height / 2)
        path.cubicTo(+self.width / 2, -self.height / 2,
                     +self.width / 2, -self.height / 2,
                     +self.width / 2, 0)
        path.cubicTo(+self.width / 2, +self.height / 2,
                     +self.width / 2, +self.height / 2,
                     0, +self.height / 2)
        path.cubicTo(-self.width / 2, +self.height / 2,
                     -self.width / 2, +self.height / 2,
                     -self.width / 2, 0)
        path.closeSubpath()

        c = self.parent_node.color
        body_gradient = QLinearGradient(self.boundingRect().bottomLeft(),
                                        self.boundingRect().topRight())
        body_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(), 150))
        body_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 80))

        painter.setBrush(body_gradient)
        painter.setPen(QPen(QColor(30, 43, 48)))

        painter.drawPath(path)
Beispiel #23
0
    def drawBar(self, painter: QPainter) -> None:
        """ 绘制当前条目选中背景 """
        painter.save()
        pen: QPen = QPen()  # PySide2.QtGui.QPen

        barGradient: QLinearGradient = QLinearGradient(
            self.__barRect.topLeft(), self.__barRect.bottomLeft())
        barGradient.setColorAt(0.0, self.__barColorStart)
        barGradient.setColorAt(1.0, self.__barColorEnd)
        painter.setBrush(barGradient)

        if self.barStyle == NavBar.BarStyle.BARSTYLE_RECT:
            painter.setPen(Qt.NoPen)
            painter.drawRoundedRect(self.__barRect, self.__barRadius,
                                    self.__barRadius)
            painter.restore()
            return
        else:
            pen.setWidthF(self.__lineWidth)
            pen.setBrush(barGradient)
            painter.setPen(pen)
            painter.drawRoundedRect(self.__barRect, self.__barRadius,
                                    self.__barRadius)

        pen.setColor(self.__lineColor)
        painter.setPen(pen)

        offset: Decimal = Decimal(self.__lineWidth) / 2
        if self.__barStyle == NavBar.BarStyle.BARSTYLE_LINE_TOP:
            painter.drawLine(int(self.__barRect.left()),
                             self.__barRect.top() + offset,
                             int(self.__barRect.right()),
                             self.__barRect.top() + offset)
        elif self.__barStyle == NavBar.BarStyle.BARSTYLE_LINE_TOP:
            painter.drawLine(self.__barRect.right() - offset,
                             int(self.__barRect.top()),
                             self.__barRect.right() - offset,
                             int(self.__barRect.bottom()))
        elif self.__barStyle == NavBar.BarStyle.BARSTYLE_LINE_TOP:
            painter.drawLine(int(self.__barRect.left()),
                             self.__barRect.bottom() - offset,
                             int(self.__barRect.right()),
                             self.__barRect.bottom() - offset)
        elif self.__barStyle == NavBar.BarStyle.BARSTYLE_LINE_TOP:
            painter.drawLine(self.__barRect.left() + offset,
                             int(self.__barRect.top()),
                             self.__barRect.left() + offset,
                             int(self.__barRect.bottom()))

        # 这里还可以增加右侧倒三角型

        painter.restore()
    def draw_blender_extended_background(self, painter, c, w, h,
                                         bounding_rect):
        """
        :param painter: painter from paint event
        :param c: NodeInstance's theme color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        """
        background_color = QColor(100, 100, 100, 150)
        header_color = QColor(c.red(), c.green(), c.blue(), 180)

        rel_header_height = self.get_header_rect(w, h).height() / h
        gradient = QLinearGradient(bounding_rect.topLeft(),
                                   bounding_rect.bottomLeft())
        gradient.setColorAt(0, header_color)
        gradient.setColorAt(rel_header_height, header_color)
        gradient.setColorAt(rel_header_height + 0.0001, background_color)
        gradient.setColorAt(1, background_color)

        painter.setBrush(gradient)
        painter.setPen(QPen(c.darker()))
        painter.drawRoundedRect(bounding_rect, 7, 7)
Beispiel #25
0
    def draw_tron_extended_background(self, painter):
        # main rect
        c = QColor('#212224')
        painter.setBrush(c)
        pen = QPen(self.parent_node.color)
        pen.setWidth(2)
        painter.setPen(pen)
        body_path = self.get_extended_body_path_TRON_DESIGN(10)
        painter.drawPath(body_path)
        # painter.drawRoundedRect(self.boundingRect(), 12, 12)

        c = self.parent_node.color
        header_gradient = QLinearGradient(self.get_header_rect().topRight(), self.get_header_rect().bottomLeft())
        header_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(), 255))
        header_gradient.setColorAt(0.5, QColor(c.red(), c.green(), c.blue(), 100))
        header_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 0))
        painter.setBrush(header_gradient)
        header_path = self.get_extended_header_path_TRON_DESIGN(10)
        painter.drawPath(header_path)
 def _draw_bar_background(self, p: QPainter):
     """
     绘制导航栏的背景
     :param p: 画刷
     :return: None
     """
     p.save()
     p.setPen(Qt.NoPen)
     lgt = QLinearGradient(QPointF(0, 0), QPointF(0, self.height()))
     lgt.setColorAt(0.0, self._m_bar_start_color)
     lgt.setColorAt(1.0, self._m_bar_end_color)
     p.setBrush(lgt)
     p.drawRoundedRect(self.rect(), self._m_bar_radius, self._m_bar_radius)
     p.restore()
Beispiel #27
0
    def drawBg(self, painter: QPainter) -> None:
        painter.save()

        # 不可用背景灰色
        if self.isEnabled():
            linearGradient: QLinearGradient = QLinearGradient()

            if self.__hsbMode:
                # 起始坐标和结束坐标换个位置可改变颜色顺序
                linearGradient.setStart(
                    QPoint(self.__bgRect.x(), self.__bgRect.height()))
                linearGradient.setFinalStop(
                    QPoint(self.__bgRect.x(), self.__bgRect.y()))

                # 由下往上,饱和度百分值由0增加到1.0
                for i in [i * 0.0625 for i in range(17)]:
                    linearGradient.setColorAt(i, QColor.fromHsvF(i, 1, 1, 1))

                painter.setPen(Qt.NoPen)
            else:
                linearGradient.setStart(QPointF(0, 0))
                linearGradient.setFinalStop(QPointF(0, self.height()))
                linearGradient.setColorAt(0.0, self.__topColor)
                linearGradient.setColorAt(1.0, self.__bottomColor)

                pen: QPen = QPen()
                pen.setWidthF(self.__borderWidth)
                pen.setColor(self.__borderColor)
                pen.setCapStyle(Qt.RoundCap)
                pen.setJoinStyle(Qt.RoundJoin)
                painter.setPen(pen)

            painter.setBrush(linearGradient)
        else:
            painter.setPen(Qt.NoPen)
            painter.setBrush(self.__disableColor)

        painter.drawRoundedRect(self.__bgRect, self.__borderRadius,
                                self.__borderRadius)

        painter.restore()
    def __init__(self, parent, scene: QGraphicsScene):
        super().__init__(parent)
        self.setRenderHints(QPainter.Antialiasing)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)

        gradient = QLinearGradient(self.rect().topLeft(),
                                   self.rect().bottomRight())
        gradient.setColorAt(0, Qt.white)
        gradient.setColorAt(1, Qt.lightGray)

        self.setCursor(Qt.CrossCursor)  # 设置鼠标
        self.setMouseTracking(True)
        self.setDragMode(QGraphicsView.RubberBandDrag)

        self.setBackgroundBrush(gradient)
        self.setScene(scene)
        self.setAttribute(Qt.WA_DeleteOnClose)
Beispiel #29
0
    def draw_NI_extended_background(painter, c, w, h, bounding_rect,
                                    title_rect):
        """
        :param painter: painter from paint event
        :param c: NodeInstance's theme color
        :param w: width
        :param h: height
        :param bounding_rect: NodeInstance's bounding rect
        :param title_rect: NI's title label's bounding rect
        """

        # main rect
        body_gradient = QRadialGradient(bounding_rect.topLeft(),
                                        pythagoras(h, w))
        body_gradient.setColorAt(
            0,
            QColor(c.red() / 10 + 100,
                   c.green() / 10 + 100,
                   c.blue() / 10 + 100, 200))
        body_gradient.setColorAt(
            1,
            QColor(c.red() / 10 + 100,
                   c.green() / 10 + 100,
                   c.blue() / 10 + 100, 0))

        painter.setBrush(body_gradient)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(bounding_rect, 12, 12)

        header_gradient = QLinearGradient(
            NIPainter_DarkStd.get_header_rect(w, h, title_rect).topRight(),
            NIPainter_DarkStd.get_header_rect(w, h, title_rect).bottomLeft())
        header_gradient.setColorAt(0, QColor(c.red(), c.green(), c.blue(),
                                             255))
        header_gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), 0))
        painter.setBrush(header_gradient)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(
            NIPainter_DarkStd.get_header_rect(w, h, title_rect), 12, 12)
Beispiel #30
0
    def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
        """
        重载paintEvent函数
        :param a0:
        :return:
        """
        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)
        p.save()
        p.setPen(Qt.NoPen)

        lgt = QLinearGradient(QPointF(0, 0), QPointF(self.width(), 0))
        lgt.setColorAt(0.0, QColor('#511235'))
        lgt.setColorAt(1.0, QColor('red'))
        p.setBrush(lgt)
        p.drawRect(QRectF(0, 0, self.width(), self._m_title_height))
        p.drawRect(
            QRectF(0,
                   self.height() - self._m_status_label.height(),
                   self.rect().width(), self._m_status_label.height()))
        line_pen = QPen()
        line_pen.setColor(QColor(30, 144, 255, 30))
        line_pen.setWidth(1)
        p.setPen(line_pen)
        p.drawLine(0,
                   self.rect().height() - self._m_status_label.height(),
                   self.rect().width(),
                   self.rect().height() - self._m_status_label.height())

        # 在窗口左上角画图标

        if self._m_icon_path:
            imx = QPixmap(self._m_icon_path)
            p.drawPixmap(5, (self._m_title_label.height() - imx.height()) / 2,
                         imx)

        p.restore()
    def paint(self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget = None):
        # setup border pen
        pen = painter.pen()
        pen.setWidthF(self.monitor_border_width)
        pen.setCapStyle(Qt.FlatCap)
        painter.setPen(pen)

        # create monitor_rect
        rect_monitor = QRectF(0, 0,
                              self.monitor.screen_width, self.monitor.screen_height)

        # Draw gradient in the background
        gradient = QLinearGradient(rect_monitor.topRight(), rect_monitor.bottomLeft())
        gradient.setColorAt(0.0, self.monitor_color_gradient_top)
        gradient.setColorAt(1.0, self.monitor_color_gradient_bottom)
        painter.fillRect(rect_monitor, gradient)

        # draw monitor label
        self.draw_monitor_label(painter, rect_monitor, self.index)

        # draw borders inside monitor_rect
        border_offset = painter.pen().widthF() / 2
        border_rect = rect_monitor.adjusted(border_offset, border_offset, -border_offset, border_offset)
        painter.drawRect(border_rect)