Simple fill pattern in svg : diagonal hatching

后端 未结 11 1851
轮回少年
轮回少年 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 08:54

    One problem with drawing a diagonal line within a pattern is that when the pattern is tiled the lines won't always line up - especially at high zooms. (It depends on the SVG rendering engine you happen to be using). @Ingo's answer above attempts to resolve this by drawing in the triangles at the top-left and bottom-right corners - but again, using some rendering engines and high zooms, it doesn't always look best - and sometimes the line ends up looking a bit like a string of sausages.

    Another approach is to draw a horizontal line in the pattern and rotate the pattern, e.g.

      
    
      
        
      
    
    
    

提交回复
热议问题