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


Python QTransform.fromTranslate方法代码示例

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


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

示例1: resolve_fill

# 需要导入模块: from PyQt5.Qt import QTransform [as 别名]
# 或者: from PyQt5.Qt.QTransform import fromTranslate [as 别名]
    def resolve_fill(self, rect, pdf_system, qt_system):
        '''
        Qt's paint system does not update brushOrigin when using
        TexturePatterns and it also uses TexturePatterns to emulate gradients,
        leading to brokenness. So this method allows the paint engine to update
        the brush origin before painting an object. While not perfect, this is
        better than nothing. The problem is that if the rect being filled has a
        border, then QtWebKit generates an image of the rect size - border but
        fills the full rect, and there's no way for the paint engine to know
        that and adjust the brush origin.
        '''
        if not hasattr(self, 'last_fill') or not self.current_state.do_fill:
            return

        if isinstance(self.last_fill.brush, TexturePattern):
            tl = rect.topLeft()
            if tl == self.last_fill.origin:
                return

            matrix = (QTransform.fromTranslate(tl.x(), tl.y())
                * pdf_system * qt_system.inverted()[0])

            pat = TexturePattern(None, matrix, self.pdf, clone=self.last_fill.brush)
            pattern = self.pdf.add_pattern(pat)
            self.pdf.apply_fill(self.last_fill.color, pattern)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:27,代码来源:graphics.py

示例2: convert_brush

# 需要导入模块: from PyQt5.Qt import QTransform [as 别名]
# 或者: from PyQt5.Qt.QTransform import fromTranslate [as 别名]
    def convert_brush(self, brush, brush_origin, global_opacity,
                      pdf_system, qt_system):
        # Convert a QBrush to PDF operators
        style = brush.style()
        pdf = self.pdf

        pattern = color = pat = None
        opacity = global_opacity
        do_fill = True

        matrix = (QTransform.fromTranslate(brush_origin.x(), brush_origin.y())
                  * pdf_system * qt_system.inverted()[0])
        vals = list(brush.color().getRgbF())
        self.brushobj = None

        if style <= Qt.DiagCrossPattern:
            opacity *= vals[-1]
            color = vals[:3]

            if style > Qt.SolidPattern:
                pat = QtPattern(style, matrix)

        elif style == Qt.TexturePattern:
            pat = TexturePattern(brush.texture(), matrix, pdf)
            if pat.paint_type == 2:
                opacity *= vals[-1]
                color = vals[:3]

        elif style == Qt.LinearGradientPattern:
            pat = LinearGradientPattern(brush, matrix, pdf, self.page_width_px,
                                        self.page_height_px)
            opacity *= pat.const_opacity
        # TODO: Add support for radial/conical gradient fills

        if opacity < 1e-4 or style == Qt.NoBrush:
            do_fill = False
        self.brushobj = Brush(brush_origin, pat, color)

        if pat is not None:
            pattern = pdf.add_pattern(pat)
        return color, opacity, pattern, do_fill
开发者ID:AtulKumar2,项目名称:calibre,代码行数:43,代码来源:graphics.py


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