| 126 | } |
| 127 | |
| 128 | func TestParseSVGPatternCurrentColor(t *testing.T) { |
| 129 | svg := `<svg width="100" height="100"> |
| 130 | <defs> |
| 131 | <pattern id="hatch" patternUnits="userSpaceOnUse" width="6" height="6" patternTransform="rotate(45)"> |
| 132 | <line x1="0" y1="0" x2="0" y2="6" stroke="currentColor" stroke-width="1" stroke-opacity="0.7"/> |
| 133 | </pattern> |
| 134 | </defs> |
| 135 | <circle cx="50" cy="50" r="40" fill="url(#hatch)" style="color:rgb(0,255,0)"/> |
| 136 | </svg>` |
| 137 | |
| 138 | c, err := ParseSVG(strings.NewReader(svg)) |
| 139 | test.Error(t, err) |
| 140 | |
| 141 | if len(c.layers) == 0 || len(c.layers[0]) == 0 { |
| 142 | t.Fatal("no layers rendered") |
| 143 | } |
| 144 | |
| 145 | layer := c.layers[0][0] |
| 146 | if !layer.style.Fill.IsPattern() { |
| 147 | t.Fatal("expected fill to be a pattern") |
| 148 | } |
| 149 | |
| 150 | hatch, ok := layer.style.Fill.Pattern.(*HatchPattern) |
| 151 | if !ok { |
| 152 | t.Fatal("expected HatchPattern") |
| 153 | } |
| 154 | |
| 155 | expected := color.RGBA{0, 178, 0, 178} |
| 156 | test.T(t, hatch.Fill.Color, expected) |
| 157 | } |