| 191 | } |
| 192 | |
| 193 | func (p Paths) ToSVG(width, height float64) string { |
| 194 | var lines []string |
| 195 | lines = append(lines, fmt.Sprintf("<svg width=\"%f\" height=\"%f\" version=\"1.1\" baseProfile=\"full\" xmlns=\"http://www.w3.org/2000/svg\">", width, height)) |
| 196 | lines = append(lines, fmt.Sprintf("<g transform=\"translate(0,%f) scale(1,-1)\">", height)) |
| 197 | for _, path := range p { |
| 198 | lines = append(lines, path.ToSVG()) |
| 199 | } |
| 200 | lines = append(lines, "</g></svg>") |
| 201 | return strings.Join(lines, "\n") |
| 202 | } |
| 203 | |
| 204 | func (p Paths) WriteToSVG(path string, width, height float64) error { |
| 205 | return ioutil.WriteFile(path, []byte(p.ToSVG(width, height)), 0644) |