Example #1
0
           def representK(value):
       # returns CMS color if available
               if ( re.search("icc-color", value.group()) ):
                   return simplestyle.formatColor3f(float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])))
 
               red =   float(simplestyle.parseColor(str(value.group()))[0]/255.00)
               green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
               blue =  float(simplestyle.parseColor(str(value.group()))[2]/255.00)
               return simplestyle.formatColor3f(float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]))
Example #2
0
def representK(value):
    # returns CMS color if available
    if (re.search("icc-color", value.group()) ):
        return simplestyle.formatColor3f(float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])))
    else:
        red =   float(simplestyle.parseColor(str(value.group()))[0]/255.00)
        green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
        blue =  float(simplestyle.parseColor(str(value.group()))[2]/255.00)
        return simplestyle.formatColor3f(float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]))
Example #3
0
 def represent(value):
     red = float(
         simplestyle.parseColor(str(value.group()))[0] / 255.00)
     green = float(
         simplestyle.parseColor(str(value.group()))[1] / 255.00)
     blue = float(
         simplestyle.parseColor(str(value.group()))[2] / 255.00)
     return str(
         str(simplestyle.formatColor3f(red, green, blue)) +
         ' device-cmyk(' +
         str(calculateCMYK(red, green, blue)[0]) + ' ' +
         str(calculateCMYK(red, green, blue)[1]) + ' ' +
         str(calculateCMYK(red, green, blue)[2]) + ' ' +
         str(calculateCMYK(red, green, blue)[3]) + ')')
    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')
Example #5
0
 def represent(value):
     red =   float(simplestyle.parseColor(str(value.group()))[0]/255.00)
     green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
     blue =  float(simplestyle.parseColor(str(value.group()))[2]/255.00)
     return str(str(simplestyle.formatColor3f(red,green,blue)) + ' device-cmyk(' + str(calculateCMYK(red, green, blue)[0]) + ' ' + str(calculateCMYK(red, green, blue)[1]) + ' ' + str(calculateCMYK(red, green, blue)[2]) + ' ' + str(calculateCMYK(red, green, blue)[3]) + ')')