Subtract one circle from another in SVG

前端 未结 4 1905
自闭症患者
自闭症患者 2021-02-01 14:12

I\'m trying to find a way to subtract one shape from another in SVG, creating a hole in the middle or a bite out of the side of it. Kind of like a clipping path, but instead of

4条回答
  •  故里飘歌
    2021-02-01 14:51

    The trick is to use fill-rule to control the display of a clip-path. A (square) donut example would be

    
    
    
    
    
    
       
          
       
    
    

    That uses the fill-rule property of shapes to remove the inner square - you could adjust that to be done with bezier paths to create a circle as required.

    Once you've got the basic clipping path created, you can create a clipping path out of it - see this MDN entry for info on clip-path.

提交回复
热议问题