Simple fill pattern in svg : diagonal hatching

后端 未结 11 1846
轮回少年
轮回少年 2020-12-04 08:28

How would I fill an SVG shape, not with a single colour, an image or a gradient, but with a hatching pattern, diagonal if possible.

It\'s been 2 hours and I\'ve foun

11条回答
  •  时光取名叫无心
    2020-12-04 09:10

    This code from http://bl.ocks.org/jfsiii/7772281 seems very clean and reusable:

    svg {
      width: 500px;
      height: 500px;
    }
    
    rect.hbar {
      mask: url(#mask-stripe)
    }
    
    .thing-1 {
      fill: blue;
    }
    
    
    .thing-2 {
      fill: green;
    }
        
        
          
            
            SVG colored patterns via mask
          
          
            
              
                
                  
                
                
                  
                      
              
        
              
              
              
              
              
              
              
              
              
              
            
          
        

提交回复
热议问题