2017-12-16 18:26:34 +00:00
|
|
|
package draw2dsvg
|
|
|
|
|
|
|
|
import (
|
2017-12-21 17:18:29 +00:00
|
|
|
"encoding/xml"
|
2017-12-21 14:52:26 +00:00
|
|
|
_ "errors"
|
2018-01-07 16:57:38 +00:00
|
|
|
"os"
|
2017-12-16 18:26:34 +00:00
|
|
|
)
|
|
|
|
|
2017-12-21 17:18:29 +00:00
|
|
|
func SaveToSvgFile(filePath string, svg *Svg) error {
|
2017-12-16 18:26:34 +00:00
|
|
|
f, err := os.Create(filePath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
2017-12-21 17:18:29 +00:00
|
|
|
f.Write([]byte(xml.Header))
|
|
|
|
encoder := xml.NewEncoder(f)
|
|
|
|
encoder.Indent("", "\t")
|
|
|
|
err = encoder.Encode(svg)
|
2017-12-16 18:26:34 +00:00
|
|
|
|
2017-12-21 17:18:29 +00:00
|
|
|
return err
|
2018-01-07 16:57:38 +00:00
|
|
|
}
|