diff --git a/README.markdown b/README.markdown index 0526c06..722d499 100644 --- a/README.markdown +++ b/README.markdown @@ -149,6 +149,7 @@ A video describing how to use the package can be seen on YouTube at tag + Width int `xml:"width,attr"` + Height int `xml:"height,attr"` + // Doc is all all of the contents within the tags, specified by the + // `innerxml` struct tag + Doc []byte `xml:",innerxml"` +} + +func parseSVG(src io.Reader) (SVG, error) { + var s SVG + data, err := io.ReadAll(src) + if err != nil { + return SVG{}, err + } + if xml.Unmarshal(data, &s); err != nil { + return SVG{}, err + } + return s, nil +} + +func placeHeader(width, height int, name string) { + // add border + canvas.Rect(0, 0, width, height, fmt.Sprintf(borderfmt, borderSize)) + // add title from file name + canvas.Text(width/2, titleHeight*3/4, name, fmt.Sprintf(titlefmt, width)) +} + +func placeSVG(s SVG) { + // create clip path of svg size + canvas.Group(`clip-path="url(#embed)"`, fmt.Sprintf(groupfmt, borderSize, titleHeight+borderSize)) + canvas.ClipPath(`id="embed"`) + canvas.Rect(0, 0, s.Width, s.Height) + canvas.ClipEnd() + // append embedded svg + canvas.Writer.Write(s.Doc) + canvas.Gend() + canvas.End() +} + +func init() { + flag.StringVar(&filename, "f", "embed.svg", "file name") + flag.Parse() +} + +func main() { + if err := embed(); err != nil { + fmt.Fprintf(os.Stdout, "error: %v\n", err) + os.Exit(1) + } +}