Exemple #1
0
    def testTwoColor(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        line = QgsLineburstSymbolLayer()
        line.setColor(QColor(255, 0, 0))
        line.setColor2(QColor(0, 255, 0))
        line.setWidth(8)

        s.appendSymbolLayer(line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        self.assertTrue(
            self.imageCheck('lineburst_two_color', 'lineburst_two_color',
                            rendered_image))
Exemple #2
0
    def testRenderBevelJoin(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        line = QgsLineburstSymbolLayer()
        line.setColor(QColor(255, 0, 0))
        line.setColor2(QColor(0, 255, 0))
        line.setWidth(8)
        line.setPenJoinStyle(Qt.BevelJoin)

        s.appendSymbolLayer(line.clone())

        g = QgsGeometry.fromWkt('LineString(2 2, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        self.assertTrue(
            self.imageCheck('lineburst_beveljoin', 'lineburst_beveljoin',
                            rendered_image))
Exemple #3
0
    def testRenderFlatCap(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        line = QgsLineburstSymbolLayer()
        line.setColor(QColor(255, 0, 0))
        line.setColor2(QColor(0, 255, 0))
        line.setWidth(8)
        line.setPenCapStyle(Qt.FlatCap)

        s.appendSymbolLayer(line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        self.assertTrue(
            self.imageCheck('lineburst_flatcap', 'lineburst_flatcap',
                            rendered_image))
Exemple #4
0
    def testColorRamp(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        line = QgsLineburstSymbolLayer()
        line.setGradientColorType(Qgis.GradientColorSource.ColorRamp)
        line.setColorRamp(
            QgsGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), False,
                                 [QgsGradientStop(0.5, QColor(0, 0, 200))]))
        line.setWidth(8)

        s.appendSymbolLayer(line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        self.assertTrue(
            self.imageCheck('lineburst_colorramp', 'lineburst_colorramp',
                            rendered_image))
Exemple #5
0
    def testDataDefinedColors(self):
        s = QgsLineSymbol()
        s.deleteSymbolLayer(0)

        line = QgsLineburstSymbolLayer()
        line.setColor(QColor(255, 0, 0))
        line.setColor2(QColor(0, 255, 0))
        line.setWidth(8)
        line.setDataDefinedProperty(QgsSymbolLayer.PropertyStrokeColor,
                                    QgsProperty.fromExpression("'orange'"))
        line.setDataDefinedProperty(QgsSymbolLayer.PropertySecondaryColor,
                                    QgsProperty.fromExpression("'purple'"))

        s.appendSymbolLayer(line.clone())

        g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
        rendered_image = self.renderGeometry(s, g)
        self.assertTrue(
            self.imageCheck('lineburst_datadefined_color',
                            'lineburst_datadefined_color', rendered_image))