2017-12-16 18:26:34 +00:00
|
|
|
package draw2dsvg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"bytes"
|
2017-12-21 14:52:26 +00:00
|
|
|
_ "errors"
|
2017-12-16 18:26:34 +00:00
|
|
|
)
|
|
|
|
|
2017-12-21 14:52:26 +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 14:52:26 +00:00
|
|
|
bytes.NewBuffer((*bytes.Buffer)(svg).Bytes()).WriteTo(f) // clone buffer to make multiple writes possible
|
2017-12-16 18:26:34 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|