Beispiel #1
0
 def parse_color(self, color_text):
     """Parse the color text input from the extension dialog."""
     try:
         if color_text and color_text.lower() != 'none':
             return simplestyle.formatColoria(simplestyle.parseColor(color_text))
     except:
         pass
     return 'none'
Beispiel #2
0
 def change_colors(origin, tipo_cor):
     for i in range(len(str(origin).split(tipo_cor + ':'))):
         if str(str(origin).split(tipo_cor + ':')[i].split(';')
                [0]) in simplestyle.svgcolors.keys():
             numeros_da_cor = simplestyle.formatColoria(
                 simplestyle.parseColor(
                     str(
                         str(origin).split(tipo_cor +
                                           ':')[i].split(';')[0])))
             origin = str(origin).replace(
                 ':' +
                 str(str(origin).split(tipo_cor + ':')[i].split(';')[0]) +
                 ';', ':' + numeros_da_cor + ';')
     return origin
    def test_simplestyle(self):
        """Test simplestyle API"""
        import simplestyle

        self.assertEqual(simplestyle.svgcolors['blue'], '#0000ff')
        self.assertEqual(simplestyle.parseStyle('foo: bar; abc-def: 123em'), {
            'foo': 'bar',
            'abc-def': '123em'
        })
        self.assertEqual(simplestyle.formatStyle({'foo': 'bar'}), 'foo:bar')
        self.assertTrue(simplestyle.isColor('#ff0000'))
        self.assertTrue(simplestyle.isColor('#f00'))
        self.assertTrue(simplestyle.isColor('blue'))
        self.assertFalse(simplestyle.isColor('none'))
        self.assertFalse(simplestyle.isColor('nosuchcolor'))
        self.assertEqual(simplestyle.parseColor('#0000ff'), (0, 0, 0xff))
        self.assertEqual(simplestyle.parseColor('red'), (0xff, 0, 0))
        self.assertEqual(simplestyle.formatColoria([0, 0x99, 0]), '#009900')
        self.assertEqual(simplestyle.formatColor3i(0, 0x99, 0), '#009900')
        self.assertEqual(simplestyle.formatColorfa([0, 1.0, 0]), '#00ff00')
        self.assertEqual(simplestyle.formatColor3f(0, 1.0, 0), '#00ff00')
Beispiel #4
0
    def getNodeAndLabelColourForGradient(self, gradientNode):
        stops = self.getGradientStops(gradientNode)

        nodeColours = []

        for stop in stops:
            offset = float(stop[0])
            colour = stop[1]
            nodeColours.append("{colour:s}{offset:s}".format(
                colour=colour,
                offset="" if offset in (0,
                                        1) else " ({:0.2f})".format(offset)))
        nodeColour = u" ↔ ".join(nodeColours)

        avgNodeColour = [
            sum([simplestyle.parseColor(stop[1])[c]
                 for stop in stops]) / len(stops) for c in range(3)
        ]

        labelColour = \
            self.getLabelColour(simplestyle.formatColoria(avgNodeColour))

        return (nodeColour, labelColour)
def addColor(col):
    if simplestyle.isColor(col):
        c = simplestyle.parseColor(col)
        colors["%3i %3i %3i " % (c[0], c[1], c[2])] = simplestyle.formatColoria(c).upper()
def addColor(col):
    if simplestyle.isColor(col):
        c = simplestyle.parseColor(col)
        colors['%3i %3i %3i ' %
               (c[0], c[1], c[2])] = simplestyle.formatColoria(c).upper()
Beispiel #7
0
 def change_colors(origin, tipo_cor):
     for i in range(len(str(origin).split(tipo_cor + ':'))):
         if str(str(origin).split(tipo_cor + ':')[i].split(';')[0]) in simplestyle.svgcolors.keys():
             numeros_da_cor = simplestyle.formatColoria(simplestyle.parseColor(str(str(origin).split(tipo_cor + ':')[i].split(';')[0])))
             origin = str(origin).replace(':' + str(str(origin).split(tipo_cor + ':')[i].split(';')[0]) + ';', ':' + numeros_da_cor + ';')
     return origin