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


Python QtGui.QPainter方法代码示例

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


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

示例1: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, event):

        super(CircularBrush, self).paintEvent(event)

        # draw brush
        if hasattr(self, 'brush_state') and self.brush_state.draw:
            painter = QPainter()
            shapes = self.create_brush_shape()
            for shape in shapes:
                shape = [QPointF(point[0], point[1]) for point in shape]

                path = QPainterPath()
                start_pos = shape.pop(0)
                path.moveTo(start_pos)
                [path.lineTo(point) for point in shape]

                painter.setRenderHint(painter.Antialiasing)
                #  painter.setRenderHint(painter.HighQualityAnti)
                painter.begin(self)

                painter.setPen(QPen(Qt.red, 1))
                painter.drawPath(path)

            painter.end() 
开发者ID:wiremas,项目名称:spore,代码行数:26,代码来源:canvas.py

示例2: _brush

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def _brush(self, b: Brush, p: QPainter):
        """Configure the given brush."""
        brush = None

        if b.index is not None:  # This is a cached brush.
            brush = self.brushes.get(b.index)
        elif b.style == BrushStyle.PATTERN:
            pm = QPixmap.loadFromData(b.data, _fmt[b.bpp])
            brush = QBrush(pm)
        elif b.style == BrushStyle.HATCHED:
            brush = QBrush(_hs[b.hatch])
        else:
            brush = QBrush(_bs[b.style])

        p.setBrush(brush)
        p.setBrushOrigin(b.x, b.y)

    # Drawing API. 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:20,代码来源:draw.py

示例3: draw

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def draw(self, glyph: GlyphEntry, p: QPainter):
        """Render a glyph using the given painter."""
        # Adjust the glyph coordinates to center it on origin
        x = self.x + glyph.x
        y = self.y + glyph.y

        if not self.fOpRedundant:
            p.fillRect(x, y, glyph.w, glyph.h, rgb_to_qcolor(self.fg))

        p.setBrush(QBrush(rgb_to_qcolor(self.bg), glyph.bitmap))
        p.setBrushOrigin(x, y)
        p.drawRect(x, y, glyph.w, glyph.h)

        if self.flAccel & SO_CHAR_INC_EQUAL_BM_BASE:
            self.x += glyph.w


# Map brush styles to Qt brush style 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:20,代码来源:draw.py

示例4: notifyImage

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def notifyImage(self, x: int, y: int, qimage: QImage, width: int, height: int):
        """
        Draw an image on the buffer.
        :param x: x position of the new image
        :param y: y position of the new image
        :param qimage: new QImage
        :param width: width of the new image
        :param height: height of the new image
        """

        # Fill buffer image
        qp = QPainter(self._buffer)
        qp.drawImage(x, y, qimage, 0, 0, width, height)

        # Force update
        self.update() 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:18,代码来源:qt.py

示例5: __getCompositionMode

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def __getCompositionMode(self):
		v = self.blendMode

		if v == BlendMode.SOURCE_ATOP:
			return QtGui.QPainter.CompositionMode_SourceAtop
		elif v == BlendMode.SOURCE_IN:
			return QtGui.QPainter.CompositionMode_SourceIn
		elif v == BlendMode.SOURCE_OUT:
			return QtGui.QPainter.CompositionMode_SourceOut
		elif v == BlendMode.DESTINATION_OVER:
			return QtGui.QPainter.CompositionMode_DestinationOver
		elif v == BlendMode.DESTINATION_ATOP:
			return QtGui.QPainter.CompositionMode_DestinationAtop
		elif v == BlendMode.DESTINATION_IN:
			return QtGui.QPainter.CompositionMode_DestinationIn
		elif v == BlendMode.DESTINATION_OUT:
			return QtGui.QPainter.CompositionMode_DestinationOut
		elif v == BlendMode.LIGHTER:
			return QtGui.QPainter.CompositionMode_Lighter
		elif v == BlendMode.COPY:
			return QtGui.QPainter.CompositionMode_Copy
		elif v == BlendMode.XOR:
			return QtGui.QPainter.CompositionMode_Xor
		else:
			return QtGui.QPainter.CompositionMode_SourceOver 
开发者ID:yuehaowang,项目名称:pylash_engine,代码行数:27,代码来源:display.py

示例6: draw

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def draw(self, source):
		if not isinstance(source, DisplayObject):
			raise TypeError("BitmapData.draw(source): parameter 'source' must be a display object.")

		w = source.endX()
		h = source.endY()

		self.image = QtGui.QPixmap(w, h)
		self.image.fill(QtCore.Qt.transparent)
		
		p = QtGui.QPainter()
		p.begin(self.image)

		if stage.useAntialiasing:
			p.setRenderHint(QtGui.QPainter.Antialiasing, True)
		else:
			p.setRenderHint(QtGui.QPainter.Antialiasing, False)

		source._show(p)

		p.end()

		self.width = w
		self.height = h 
开发者ID:yuehaowang,项目名称:pylash_engine,代码行数:26,代码来源:display.py

示例7: _setCanvas

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def _setCanvas(self, speed, title, width, height):
		self.speed = speed
		self.width = width
		self.height = height

		self.canvas = QtGui.QPainter()

		self.canvasWidget = CanvasWidget()
		self.canvasWidget.setWindowTitle(title)
		self.canvasWidget.setFixedSize(width, height)
		self.canvasWidget.show()

		self.timer = QtCore.QTimer()
		self.timer.setInterval(speed)
		self.timer.start()

		self.timer.timeout.connect(self.canvasWidget.update) 
开发者ID:yuehaowang,项目名称:pylash_engine,代码行数:19,代码来源:core.py

示例8: _onShow

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def _onShow(self):
		self.canvas.begin(self.canvasWidget)

		if self.useAntialiasing:
			self.canvas.setRenderHint(QtGui.QPainter.Antialiasing, True)
		else:
			self.canvas.setRenderHint(QtGui.QPainter.Antialiasing, False)

		if self.backgroundColor is not None:
			self.canvas.fillRect(0, 0, self.width, self.height, getColor(self.backgroundColor))
		else:
			self.canvas.eraseRect(0, 0, self.width, self.height)

		self._showDisplayList(self.childList)

		self.canvas.end() 
开发者ID:yuehaowang,项目名称:pylash_engine,代码行数:18,代码来源:core.py

示例9: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, event):
        painter = QPainter()
        painter.setRenderHint(painter.Antialiasing)
        #  painter.setRenderHint(painter.HighQualityAnti)

        painter.begin(self)

        print 'paint something', event
        #  path = QPainterPath()
        painter.setPen(QPen(Qt.yellow, 5))
        painter.drawEllipse(50, 50, 50, 50)



        painter.end() 
开发者ID:wiremas,项目名称:spore,代码行数:17,代码来源:draw_override.py

示例10: get_icon

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def get_icon(icon, size=24):
    """get svg icon from icon resources folder as a pixel map
    """
    img = get_icon_path("{}.svg".format(icon))
    svg_renderer = QtSvg.QSvgRenderer(img)
    image = QtGui.QImage(size, size, QtGui.QImage.Format_ARGB32)
    # Set the ARGB to 0 to prevent rendering artifacts
    image.fill(0x00000000)
    svg_renderer.render(QtGui.QPainter(image))
    pixmap = QtGui.QPixmap.fromImage(image)

    return pixmap 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:14,代码来源:pyqt.py

示例11: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, _):
        painter = QtGui.QPainter()
        painter.begin(self)
        self.paint(painter)
        painter.end() 
开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:7,代码来源:colorwheel.py

示例12: paint

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paint(self, painter):
        painter.setRenderHint(QtGui.QPainter.Antialiasing)

        pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0))
        pen.setWidth(0)
        pen.setJoinStyle(QtCore.Qt.MiterJoin)

        painter.setBrush(self._conicalGradient)
        painter.setPen(pen)
        painter.drawRoundedRect(
            6, 6, (self.width() - 12), (self.height() - 12),
            self.width(), self.height())

        painter.setBrush(self.palette().color(QtGui.QPalette.Background))
        painter.drawRoundedRect(
            12.5, 12.5, (self.width() - 25), (self.height() - 25),
            self.width(), self.height())

        self._horizontal_gradient.setColorAt(
            1.0, self._get_current_wheel_color())
        painter.setBrush(self._horizontal_gradient)
        painter.drawRect(self._rect)

        painter.setBrush(self._vertical_gradient)
        painter.drawRect(self._rect)

        pen.setColor(QtGui.QColor(BLACK))
        pen.setWidth(3)
        painter.setPen(pen)

        angle = math.radians(self._angle)
        painter.drawLine(
            get_point_on_line(angle, 37),
            get_point_on_line(angle, 46))

        pen.setWidth(5)
        pen.setCapStyle(QtCore.Qt.RoundCap)
        painter.setPen(pen)
        painter.drawPoint(self._color_point) 
开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:41,代码来源:colorwheel.py

示例13: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, _):
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        for shape in self.shapes:
            shape.draw(painter)
        painter.end() 
开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:9,代码来源:reader.py

示例14: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, event):
        super(CustomQLineEdit, self).paintEvent(event)

        painter = QtGui.QPainter(self)
        painter.setOpacity(0.75)
        height = self.iconPixmap.height()
        rightBorder = 8
        painter.drawPixmap(
            rightBorder+2, (self.height() - height) / 2, self.iconPixmap) 
开发者ID:minoue,项目名称:rush,代码行数:11,代码来源:Rush.py

示例15: paintEvent

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QPainter [as 别名]
def paintEvent(self, QPaintEvent):

        painter = QtGui.QPainter(self)

        self.pen.setColor(QtGui.QColor(80, 80, 100))
        self.pen.setWidthF(1.5)
        self.pen.setStyle(QtCore.Qt.DotLine)

        # zoom rect must be at least RUBBERBANDSIZE % of view to allow zoom
        if (QPaintEvent.rect().width() < RUBBERBANDSIZE * self.view.width()) \
            or \
           (QPaintEvent.rect().height() < RUBBERBANDSIZE * self.view.height()):

            self.brush.setStyle(QtCore.Qt.NoBrush)

            # set boolean for allowing zoom
            self.allow_zoom = False
        else:
            # if rubberband rect is big enough indicate this by fill color
            color = QtGui.QColor(10, 30, 140, 45)
            self.brush.setColor(color)
            self.brush.setStyle(QtCore.Qt.SolidPattern)

            # set boolean for allowing zoom
            self.allow_zoom = True

        painter.setBrush(self.brush)
        painter.setPen(self.pen)
        painter.drawRect(QPaintEvent.rect()) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:31,代码来源:GraphicsView.py


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