How can I merge two shapes in svg?

前端 未结 4 1072
情话喂你
情话喂你 2020-12-29 08:18

I have two shapes: circle and rectangle. Want to convert them into one figure. Are there any ways to do that in SVG code?

4条回答
  •  春和景丽
    2020-12-29 09:08

    With the feMorphology filter you can grow and shrink objects (MDN). Combining them, you can create a simply reusable outline: make an increased copy of the original, paint it, and place it under the shrunk original.

    
        
            
                
                
                
                
                
                
                
                
                
                
            
        
    
        
            
            
        
    

    If you want to have it transparent, replace the operator in the last feComposite with xor:

    
    
    

    The only caveat: fatter strokes - ie larger dilate and erode radii - on curves may look distorted, with 1px + 1px it is still fine.

提交回复
热议问题