MCPcopy Create free account
hub / github.com/fogleman/ln / ToSVG

Method ToSVG

ln/path.go:193–202  ·  view source on GitHub ↗
(width, height float64)

Source from the content-addressed store, hash-verified

191}
192
193func (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
204func (p Paths) WriteToSVG(path string, width, height float64) error {
205 return ioutil.WriteFile(path, []byte(p.ToSVG(width, height)), 0644)

Callers 1

WriteToSVGMethod · 0.95

Calls 1

ToSVGMethod · 0.45

Tested by

no test coverage detected