| 96 | } |
| 97 | |
| 98 | func TestParseSVGPatternLineHatch(t *testing.T) { |
| 99 | svg := `<svg width="100" height="100"> |
| 100 | <defs> |
| 101 | <pattern id="hatch" patternUnits="userSpaceOnUse" width="6" height="6" patternTransform="rotate(45)"> |
| 102 | <line x1="0" y1="0" x2="0" y2="6" stroke="rgb(255,0,0)" stroke-width="1"/> |
| 103 | </pattern> |
| 104 | </defs> |
| 105 | <circle cx="50" cy="50" r="40" fill="url(#hatch)"/> |
| 106 | </svg>` |
| 107 | |
| 108 | c, err := ParseSVG(strings.NewReader(svg)) |
| 109 | test.Error(t, err) |
| 110 | |
| 111 | if len(c.layers) == 0 || len(c.layers[0]) == 0 { |
| 112 | t.Fatal("no layers rendered") |
| 113 | } |
| 114 | |
| 115 | layer := c.layers[0][0] |
| 116 | if !layer.style.Fill.IsPattern() { |
| 117 | t.Fatal("expected fill to be a pattern") |
| 118 | } |
| 119 | |
| 120 | hatch, ok := layer.style.Fill.Pattern.(*HatchPattern) |
| 121 | if !ok { |
| 122 | t.Fatal("expected HatchPattern") |
| 123 | } |
| 124 | |
| 125 | test.T(t, hatch.Fill.Color, color.RGBA{255, 0, 0, 255}) |
| 126 | } |
| 127 | |
| 128 | func TestParseSVGPatternCurrentColor(t *testing.T) { |
| 129 | svg := `<svg width="100" height="100"> |