コード例 #1
0
	def get_color(self, node):
		style = simplestyle.parseStyle(node.get("style"))
		color = None
		if style.has_key("stroke"):
			if simplestyle.isColor(style["stroke"]):
				color = "%02x%02x%02x" % (simplestyle.parseColor(style["stroke"]))
				if style.has_key("stroke-opacity"):
					alpha = float(style["stroke-opacity"])
					if alpha < 1:
						color = color + "%02x" % int(alpha * 255)

		return color
コード例 #2
0
    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')
コード例 #3
0
 def process_prop(self, col):
     #debug('got:'+col)
     if simplestyle.isColor(col):
         c = simplestyle.parseColor(col)
         col = '#' + self.colmod(c[0], c[1], c[2])
         #debug('made:'+col)
     if col.startswith('url(#'):
         id = col[len('url(#'):col.find(')')]
         newid = '%s-%d' % (id, int(random.random() * 1000))
         #inkex.debug('ID:' + id )
         path = '//*[@id="%s"]' % id
         for node in xml.xpath.Evaluate(path, self.document):
             self.process_gradient(node, newid)
         col = 'url(#%s)' % newid
     return col
コード例 #4
0
ファイル: wcb_color.py プロジェクト: brucetsao/wcb-ink
	def process_prop(self,col):
		#debug('got:'+col)
		if simplestyle.isColor(col):
			c=simplestyle.parseColor(col)
			col='#'+self.colmod(c[0],c[1],c[2])
			#debug('made:'+col)
# 		if col.startswith('url(#'):
# 			id = col[len('url(#'):col.find(')')]
# 			newid = '%s-%d' % (id, int(random.random() * 1000))
# 			#inkex.debug('ID:' + id )
# 			path = '//*[@id="%s"]' % id
# 			for node in self.document.xpath(path, namespaces=inkex.NSS):
# 				self.process_gradient(node, newid)
# 			col = 'url(#%s)' % newid
		return col				
コード例 #5
0
  def process_prop(self,col):
    #debug('got:'+col)
    if simplestyle.isColor(col):
      c=simplestyle.parseColor(col)
      col='#'+self.colmod(c[0],c[1],c[2])
      #debug('made:'+col)
    if col.startswith('url(#'):
	id = col[len('url(#'):col.find(')')]
	newid = '%s-%d' % (id, int(random.random() * 1000))
	#inkex.debug('ID:' + id )
	path = '//*[@id="%s"]' % id
	for node in xml.xpath.Evaluate(path,self.document):
	  self.process_gradient(node, newid)
	col = 'url(#%s)' % newid
    return col
コード例 #6
0
def process_prop(self, col, hsbcoeffs, hsbo_cf):
    #debug('got:'+col)
    if simplestyle.isColor(col):
        c = simplestyle.parseColor(col)
        col = '#' + colmod(c[0], c[1], c[2], hsbcoeffs, hsbo_cf)
        #debug('made:'+col)
    if col.startswith('url(#'):
        id = col[len('url(#'):col.find(')')]
        newid = self.newid(self.svg_prefixfromtag(id))
        #inkex.debug('ID:' + id )
        path = '//*[@id="%s"]' % id
        for node in self.document.xpath(path, namespaces=inkex.NSS):
            process_gradient(self, node, newid, hsbcoeffs)
        col = 'url(#%s)' % newid
    return col
コード例 #7
0
ファイル: stylevariation.py プロジェクト: Alpt/gdadin
def process_prop(self, col, hsbcoeffs, hsbo_cf):
  #debug('got:'+col)
  if simplestyle.isColor(col):
    c=simplestyle.parseColor(col)
    col='#'+colmod(c[0],c[1],c[2], hsbcoeffs, hsbo_cf)
    #debug('made:'+col)
  if col.startswith('url(#'):
    id = col[len('url(#'):col.find(')')]
    newid = self.newid(self.svg_prefixfromtag(id))
    #inkex.debug('ID:' + id )
    path = '//*[@id="%s"]' % id
    for node in self.document.xpath(path, namespaces=inkex.NSS):
      process_gradient(self, node, newid, hsbcoeffs)
    col = 'url(#%s)' % newid
  return col
コード例 #8
0
ファイル: wcb_color.py プロジェクト: r3nder/wcb-ink
    def process_prop(self, col):
        #debug('got:'+col)
        if simplestyle.isColor(col):
            c = simplestyle.parseColor(col)
            col = '#' + self.colmod(c[0], c[1], c[2])
            #debug('made:'+col)


# 		if col.startswith('url(#'):
# 			id = col[len('url(#'):col.find(')')]
# 			newid = '%s-%d' % (id, int(random.random() * 1000))
# 			#inkex.debug('ID:' + id )
# 			path = '//*[@id="%s"]' % id
# 			for node in self.document.xpath(path, namespaces=inkex.NSS):
# 				self.process_gradient(node, newid)
# 			col = 'url(#%s)' % newid
        return col
コード例 #9
0
 def process_prop(self, col):
   #inkex.debug('got:'+col+str(type(col)))
   if simplestyle.isColor(col):
     c=simplestyle.parseColor(col)
     col='#'+self.colmod(c[0], c[1], c[2])
     #inkex.debug('made:'+col)
   elif col.startswith('url(#'):
     id = col[len('url(#'):col.find(')')]
     newid = '%s-%d' % (id, int(random.random() * 1000))
     #inkex.debug('ID:' + id )
     path = '//*[@id="%s"]' % id
     for node in self.document.xpath(path, namespaces=inkex.NSS):
       self.process_gradient(node, newid)
     col = 'url(#%s)' % newid
   # what remains should be opacity
   else:
     col = self.opacmod(col)
     
   #inkex.debug('col:'+str(col))
   return col
コード例 #10
0
    def process_shape(self, node, mat, group_stroke = None):
        #################################
        ### Determine the shape type  ###
        #################################
        try:
            i = node.tag.find('}')
            if i >= 0:
                tag_type = node.tag[i+1:]
        except:
            tag_type=""
        
        ##############################################
        ### Set a unique identifier for each shape ###
        ##############################################
        self.id_cnt=self.id_cnt+1
        path_id = "ID%d"%(self.id_cnt)
        sw_flag = False
        changed = False
        #######################################
        ### Handle references to CSS data   ###
        #######################################
        class_val = node.get('class')
        if class_val:
            css_data = ""
            for cv in class_val.split(' '):
                if css_data!="":
                    css_data = self.CSS_values.get_css_value(tag_type,cv)+";"+css_data
                else:
                    css_data = self.CSS_values.get_css_value(tag_type,cv)
                
            # Remove the reference to the CSS data 
            del node.attrib['class']

            # Check if a style entry already exists. If it does
            # append the the existing style data to the CSS data
            # otherwise create a new style entry.
            if node.get('style'):
                if css_data!="":
                    css_data = css_data + ";" + node.get('style')
                    node.set('style', css_data)
            else:
                node.set('style', css_data)

        style   = node.get('style')
        self.Cut_Type[path_id]="raster" # Set default type to raster

        text_message_warning = "SVG File with Color Coded Text Outlines Found: (i.e. Blue: engrave/ Red: cut)"
        line1 = "SVG File with color coded text outlines found (i.e. Blue: engrave/ Red: cut)."
        line2 = "Automatic conversion to paths failed: Try upgrading to Inkscape .90 or later"
        line3 = "To convert manually in Inkscape: select the text then select \"Path\"-\"Object to Path\" in the menu bar."
        text_message_fatal  = "%s\n\n%s\n\n%s" %(line1,line2,line3)
        
        ##############################################
        ### Handle 'style' data outside of style   ###
        ##############################################
        stroke_outside = node.get('stroke')
        if not stroke_outside:
            stroke_outside = group_stroke
        if stroke_outside:
            stroke_width_outside = node.get('stroke-width')
            
            col = stroke_outside
            col= col.strip()
            if simplestyle.isColor(col):
                c=simplestyle.parseColor(col)
                (new_val,changed,k40_action)=self.colmod(c[0],c[1],c[2],path_id)
            else:
                new_val = col
            if changed:
                node.set('stroke',new_val)
                node.set('stroke-width',"0.0")
                node.set('k40_action', k40_action)
                sw_flag = True

            if sw_flag == True:
                if node.tag == inkex.addNS('text','svg') or node.tag == inkex.addNS('flowRoot','svg'):
                    if (self.txt2paths==False):
                        raise SVG_TEXT_EXCEPTION(text_message_warning)
                    else:
                        raise Exception(text_message_fatal)

        ###################################################
        ### Handle 'k40_action' data outside of style   ###
        ###################################################
        if node.get('k40_action'):
            k40_action = node.get('k40_action')
            changed=True
            self.Cut_Type[path_id]=k40_action

        ##############################################
        ### Handle 'style' data                    ###
        ##############################################
        if style:
            declarations = style.split(';')
            i_sw = -1
            
            sw_prop = 'stroke-width'
            for i,decl in enumerate(declarations):
                parts = decl.split(':', 2)
                if len(parts) == 2:
                    (prop, col) = parts
                    prop = prop.strip().lower()
                    
                    if prop == 'k40_action':
                        changed = True
                        self.Cut_Type[path_id]=col
                        
                    #if prop in color_props:
                    if prop == sw_prop:
                        i_sw = i
                    if prop == 'stroke':
                        col= col.strip()
                        if simplestyle.isColor(col):
                            c=simplestyle.parseColor(col)
                            (new_val,changed,k40_action)=self.colmod(c[0],c[1],c[2],path_id)
                        else:
                            new_val = col
                        if changed:
                            declarations[i] = prop + ':' + new_val
                            declarations.append('k40_action' + ':' + k40_action)
                            sw_flag = True
            if sw_flag == True:
                if node.tag == inkex.addNS('text','svg') or node.tag == inkex.addNS('flowRoot','svg'):
                    if (self.txt2paths==False):
                        raise SVG_TEXT_EXCEPTION(text_message_warning)
                    else:
                        raise Exception(text_message_fatal)

                if i_sw != -1:
                    declarations[i_sw] = sw_prop + ':' + "0.0"
                else:
                    declarations.append(sw_prop + ':' + "0.0")
            node.set('style', ';'.join(declarations))
        ##############################################

        #####################################################
        ### If vector data was found save the path data   ###
        #####################################################
        if changed:
            if node.tag == inkex.addNS('path','svg'):
                d = node.get('d')
                if not d:
                    return
                p = cubicsuperpath.parsePath(d)
            elif node.tag == inkex.addNS('rect','svg'):
                x = float(node.get('x'))
                y = float(node.get('y'))
                width = float(node.get('width'))
                height = float(node.get('height'))
                rx = 0.0
                ry = 0.0
                if node.get('rx'):
                    rx=float(node.get('rx'))
                if node.get('ry'):
                    ry=float(node.get('ry'))
                    
                if max(rx,ry) > 0.0:
                    if rx==0.0 or ry==0.0:
                        rx = max(rx,ry)
                        ry = rx
                    Rxmax = abs(width)/2.0
                    Rymax = abs(height)/2.0
                    rx = min(rx,Rxmax)
                    ry = min(ry,Rymax)
                    L1 = "M %f,%f %f,%f "      %(x+rx       , y          , x+width-rx , y          )
                    C1 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+width    , y+ry       )
                    L2 = "M %f,%f %f,%f "      %(x+width    , y+ry       , x+width    , y+height-ry)
                    C2 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+width-rx , y+height   )
                    L3 = "M %f,%f %f,%f "      %(x+width-rx , y+height   , x+rx       , y+height   )
                    C3 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x          , y+height-ry)
                    L4 = "M %f,%f %f,%f "      %(x          , y+height-ry, x          , y+ry       )
                    C4 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+rx       , y          )
                    d =  L1 + C1 + L2 + C2 + L3 + C3 + L4 + C4    
                else:
                    d = "M %f,%f %f,%f %f,%f %f,%f Z" %(x,y, x+width,y,  x+width,y+height, x,y+height) 
                p = cubicsuperpath.parsePath(d)
                
            elif node.tag == inkex.addNS('circle','svg'):
                cx = float(node.get('cx') )
                cy = float(node.get('cy'))
                r  = float(node.get('r'))
                d  = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" %(cx+r,cy, r,r,cx,cy+r,  r,r,cx-r,cy,  r,r,cx,cy-r, r,r,cx+r,cy)
                p = cubicsuperpath.parsePath(d)
            
            elif node.tag == inkex.addNS('ellipse','svg'):
                cx = float(node.get('cx')) 
                cy = float(node.get('cy'))
                if node.get('r'):
                    r = float(node.get('r'))
                    rx = r
                    ry = r
                if node.get('rx'):
                    rx = float(node.get('rx'))
                if node.get('ry'):
                    ry = float(node.get('ry'))
                    
                d  = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" %(cx+rx,cy, rx,ry,cx,cy+ry,  rx,ry,cx-rx,cy,  rx,ry,cx,cy-ry, rx,ry,cx+rx,cy)
                p = cubicsuperpath.parsePath(d)
                
            elif (node.tag == inkex.addNS('polygon','svg')) or (node.tag == inkex.addNS('polyline','svg')):
                points = node.get('points')
                if not points:
                    return
               
                points = points.replace(',', ' ')
                while points.find('  ') > -1:
                    points = points.replace('  ', ' ')
                    
                points = points.strip().split(" ")
                d = "M "
                for i in range(0,len(points),2):
                    x = float(points[i])
                    y = float(points[i+1])
                    d = d + "%f,%f " %(x,y)

                #Close the loop if it is a ploygon
                if node.tag == inkex.addNS('polygon','svg'):
                    d = d + "Z"
                p = cubicsuperpath.parsePath(d)

            elif node.tag == inkex.addNS('line','svg'):
                x1 = float(node.get('x1')) 
                y1 = float(node.get('y1'))
                x2 = float(node.get('x2'))
                y2 = float(node.get('y2'))
                d = "M "
                d = "M %f,%f %f,%f" %(x1,y1,x2,y2)
                p = cubicsuperpath.parsePath(d)          
            else:
                #print("something was ignored")
                #print(node.tag)
                return
            
            trans = node.get('transform')
            if trans:
                mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
            simpletransform.applyTransformToPath(mat, p)
            
            ##########################################
            ## Break Curves down into small lines  ###
            ##########################################
            f = self.flatness
            is_flat = 0
            while is_flat < 1:
                try:
                    cspsubdiv.cspsubdiv(p, f)
                    is_flat = 1
                except IndexError:
                    break
                except:
                    f += 0.1
                    if f>2 :
                      break
                      #something has gone very wrong.
            ##########################################
            rgb=(0,0,0)
            for sub in p:
                for i in range(len(sub)-1):
                    x1 = sub[i][1][0]
                    y1 = sub[i][1][1]
                    x2 = sub[i+1][1][0]
                    y2 = sub[i+1][1][1]
                    self.lines.append([x1,y1,x2,y2,rgb,path_id])
コード例 #11
0
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()
コード例 #12
0
    def process_shape(self, node, mat):
        rgb = (0, 0, 0)
        path_id = node.get('id')
        style = node.get('style')
        self.Cut_Type[path_id] = "raster"  # Set default type to raster

        #color_props_fill = ('fill', 'stop-color', 'flood-color', 'lighting-color')
        #color_props_stroke = ('stroke',)
        #color_props = color_props_fill + color_props_stroke

        #####################################################
        ## The following is ripped off from Coloreffect.py ##
        #####################################################
        if style:
            declarations = style.split(';')
            i_sw = -1
            sw_flag = False
            sw_prop = 'stroke-width'
            for i, decl in enumerate(declarations):
                parts = decl.split(':', 2)
                if len(parts) == 2:
                    (prop, col) = parts
                    prop = prop.strip().lower()
                    #if prop in color_props:
                    if prop == sw_prop:
                        i_sw = i
                    if prop == 'stroke':
                        col = col.strip()
                        if simplestyle.isColor(col):
                            c = simplestyle.parseColor(col)
                            new_val = '#' + self.colmod(
                                c[0], c[1], c[2], path_id)
                        else:
                            new_val = col
                        if new_val != col:
                            declarations[i] = prop + ':' + new_val
                            sw_flag = True
            if sw_flag == True:
                if node.tag == inkex.addNS('text', 'svg'):
                    if (self.txt2paths == False):
                        raise SVG_TEXT_EXCEPTION(
                            "SVG File with Color Coded Text Outlines Found: (i.e. Blue: engrave/ Red: cut)"
                        )
                    else:
                        line1 = "SVG File with color coded text outlines found (i.e. Blue: engrave/ Red: cut)."
                        line2 = "Automatic conversion to paths failed: Try upgrading to Inkscape .90 or later"
                        line3 = "To convert manually in Inkscape: select the text then select \"Path\"-\"Object to Path\" in the menu bar."

                        raise StandardError("%s\n\n%s\n\n%s" %
                                            (line1, line2, line3))

                if i_sw != -1:
                    declarations[i_sw] = sw_prop + ':' + "0.0"
                else:
                    declarations.append(sw_prop + ':' + "0.0")
            node.set('style', ';'.join(declarations))

        #####################################################
        if node.tag == inkex.addNS('path', 'svg'):
            d = node.get('d')
            if not d:
                return
            p = cubicsuperpath.parsePath(d)
        elif node.tag == inkex.addNS('rect', 'svg'):
            x = float(node.get('x'))
            y = float(node.get('y'))
            width = float(node.get('width'))
            height = float(node.get('height'))
            #d = "M %f,%f %f,%f %f,%f %f,%f Z" %(x,y, x+width,y,  x+width,y+height, x,y+height)
            #p = cubicsuperpath.parsePath(d)
            rx = 0.0
            ry = 0.0
            if node.get('rx'):
                rx = float(node.get('rx'))
            if node.get('ry'):
                ry = float(node.get('ry'))

            if max(rx, ry) > 0.0:
                if rx == 0.0 or ry == 0.0:
                    rx = max(rx, ry)
                    ry = rx
                L1 = "M %f,%f %f,%f " % (x + rx, y, x + width - rx, y)
                C1 = "A %f,%f 0 0 1 %f,%f" % (rx, ry, x + width, y + ry)
                L2 = "M %f,%f %f,%f " % (x + width, y + ry, x + width,
                                         y + height - ry)
                C2 = "A %f,%f 0 0 1 %f,%f" % (rx, ry, x + width - rx,
                                              y + height)
                L3 = "M %f,%f %f,%f " % (x + width - rx, y + height, x + rx,
                                         y + height)
                C3 = "A %f,%f 0 0 1 %f,%f" % (rx, ry, x, y + height - ry)
                L4 = "M %f,%f %f,%f " % (x, y + height - ry, x, y + ry)
                C4 = "A %f,%f 0 0 1 %f,%f" % (rx, ry, x + rx, y)
                d = L1 + C1 + L2 + C2 + L3 + C3 + L4 + C4
            else:
                d = "M %f,%f %f,%f %f,%f %f,%f Z" % (
                    x, y, x + width, y, x + width, y + height, x, y + height)
            p = cubicsuperpath.parsePath(d)

        elif node.tag == inkex.addNS('circle', 'svg'):
            cx = float(node.get('cx'))
            cy = float(node.get('cy'))
            r = float(node.get('r'))
            d = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" % (
                cx + r, cy, r, r, cx, cy + r, r, r, cx - r, cy, r, r, cx,
                cy - r, r, r, cx + r, cy)
            p = cubicsuperpath.parsePath(d)

        elif node.tag == inkex.addNS('ellipse', 'svg'):
            cx = float(node.get('cx'))
            cy = float(node.get('cy'))
            rx = float(node.get('rx'))
            ry = float(node.get('ry'))
            d = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" % (
                cx + rx, cy, rx, ry, cx, cy + ry, rx, ry, cx - rx, cy, rx, ry,
                cx, cy - ry, rx, ry, cx + rx, cy)
            p = cubicsuperpath.parsePath(d)

        elif (node.tag == inkex.addNS('polygon',
                                      'svg')) or (node.tag == inkex.addNS(
                                          'polyline', 'svg')):
            points = node.get('points')
            if not points:
                return
            points = points.strip().split(" ")
            points = map(lambda x: x.split(","), points)
            d = "M "
            for point in points:
                x = float(point[0])
                y = float(point[1])
                d = d + "%f,%f " % (x, y)

            #Close the loop if it is a ploygon
            if node.tag == inkex.addNS('polygon', 'svg'):
                d = d + "Z"
            p = cubicsuperpath.parsePath(d)

        elif node.tag == inkex.addNS('line', 'svg'):
            x1 = float(node.get('x1'))
            y1 = float(node.get('y1'))
            x2 = float(node.get('x2'))
            y2 = float(node.get('y2'))
            d = "M "
            d = "M %f,%f %f,%f" % (x1, y1, x2, y2)
            p = cubicsuperpath.parsePath(d)

        else:
            return

        trans = node.get('transform')
        if trans:
            mat = simpletransform.composeTransform(
                mat, simpletransform.parseTransform(trans))
        simpletransform.applyTransformToPath(mat, p)

        ###################################################
        ## Break Curves down into small lines
        ###################################################
        f = self.flatness
        is_flat = 0
        while is_flat < 1:
            try:
                cspsubdiv.cspsubdiv(p, f)
                is_flat = 1
            except IndexError:
                break
            except:
                f += 0.1
                if f > 2:
                    break
                    #something has gone very wrong.
        ###################################################
        for sub in p:
            for i in range(len(sub) - 1):
                x1 = sub[i][1][0]
                y1 = sub[i][1][1]
                x2 = sub[i + 1][1][0]
                y2 = sub[i + 1][1][1]
                self.lines.append([x1, y1, x2, y2, rgb, path_id])
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()
コード例 #14
0
    def process_shape(self, node, mat):
        rgb = (0,0,0)
        path_id = node.get('id') 
        style   = node.get('style')
        self.Cut_Type[path_id]="raster" # Set default type to raster
        
        color_props_fill = ('fill', 'stop-color', 'flood-color', 'lighting-color')
        color_props_stroke = ('stroke',)
        color_props = color_props_fill + color_props_stroke
        
        #####################################################
        ## The following is ripped off from Coloreffect.py ##
        #####################################################
        if style:
            declarations = style.split(';')
            for i,decl in enumerate(declarations):
                parts = decl.split(':', 2)
                if len(parts) == 2:
                    (prop, col) = parts
                    prop = prop.strip().lower()
                    #if prop in color_props:
                    if prop == 'stroke':
                        col= col.strip()
                        if simplestyle.isColor(col):
                            c=simplestyle.parseColor(col)
                            new_val='#'+self.colmod(c[0],c[1],c[2],path_id)
                        else:
                            new_val = col
                        if new_val != col:
                            declarations[i] = prop + ':' + new_val
            node.set('style', ';'.join(declarations))

        #####################################################
        if node.tag == inkex.addNS('path','svg'):
            d = node.get('d')
            if not d:
                return
            p = cubicsuperpath.parsePath(d)
        elif node.tag == inkex.addNS('rect','svg'):
            x = float(node.get('x'))
            y = float(node.get('y'))
            width = float(node.get('width'))
            height = float(node.get('height'))
            #d = "M %f,%f %f,%f %f,%f %f,%f Z" %(x,y, x+width,y,  x+width,y+height, x,y+height) 
            #p = cubicsuperpath.parsePath(d)
            rx = 0.0
            ry = 0.0
            if node.get('rx'):
                rx=float(node.get('rx'))
            if node.get('ry'):
                ry=float(node.get('ry'))
                
            if max(rx,ry) > 0.0:
                if rx==0.0 or ry==0.0:
                    rx = max(rx,ry)
                    ry = rx
                msg = "rx = %f ry = %f " %(rx,ry)
                inkex.errormsg(_(msg))
                L1 = "M %f,%f %f,%f "      %(x+rx       , y          , x+width-rx , y          )
                C1 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+width    , y+ry       )
                L2 = "M %f,%f %f,%f "      %(x+width    , y+ry       , x+width    , y+height-ry)
                C2 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+width-rx , y+height   )
                L3 = "M %f,%f %f,%f "      %(x+width-rx , y+height   , x+rx       , y+height   )
                C3 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x          , y+height-ry)
                L4 = "M %f,%f %f,%f "      %(x          , y+height-ry, x          , y+ry       )
                C4 = "A %f,%f 0 0 1 %f,%f" %(rx         , ry         , x+rx       , y          )
                d =  L1 + C1 + L2 + C2 + L3 + C3 + L4 + C4    
            else:
                d = "M %f,%f %f,%f %f,%f %f,%f Z" %(x,y, x+width,y,  x+width,y+height, x,y+height) 
            p = cubicsuperpath.parsePath(d)
            
        elif node.tag == inkex.addNS('circle','svg'):
            cx = float(node.get('cx') )
            cy = float(node.get('cy'))
            r  = float(node.get('r'))
            d  = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" %(cx+r,cy, r,r,cx,cy+r,  r,r,cx-r,cy,  r,r,cx,cy-r, r,r,cx+r,cy)
            p = cubicsuperpath.parsePath(d)
        
        elif node.tag == inkex.addNS('ellipse','svg'):
            cx = float(node.get('cx')) 
            cy = float(node.get('cy'))
            rx = float(node.get('rx'))
            ry = float(node.get('ry'))
            d  = "M %f,%f A   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f   %f,%f 0 0 1 %f,%f Z" %(cx+rx,cy, rx,ry,cx,cy+ry,  rx,ry,cx-rx,cy,  rx,ry,cx,cy-ry, rx,ry,cx+rx,cy)
            p = cubicsuperpath.parsePath(d) 
        else:
            return
        trans = node.get('transform')
        if trans:
            mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
        simpletransform.applyTransformToPath(mat, p)
        
        ###################################################
        ## Break Curves down into small lines
        ###################################################
        f = self.flatness
        is_flat = 0
        while is_flat < 1:
            try:
                cspsubdiv.cspsubdiv(p, f)
                is_flat = 1
            except IndexError:
                break
            except:
                f += 0.1
                if f>2 :
                  break
                  #something has gone very wrong.
        ###################################################
        for sub in p:
            for i in range(len(sub)-1):
                s = sub[i]
                e = sub[i+1]
                self.dxf_line([s[1],e[1]],0.025,rgb,path_id)