MCPcopy
hub / github.com/fogleman/primitive / SVG

Method SVG

primitive/model.go:86–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84}
85
86func (model *Model) SVG() string {
87 bg := model.Background
88 var lines []string
89 lines = append(lines, fmt.Sprintf("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"%d\" height=\"%d\">", model.Sw, model.Sh))
90 lines = append(lines, fmt.Sprintf("<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%02x%02x%02x\" />", model.Sw, model.Sh, bg.R, bg.G, bg.B))
91 lines = append(lines, fmt.Sprintf("<g transform=\"scale(%f) translate(0.5 0.5)\">", model.Scale))
92 for i, shape := range model.Shapes {
93 c := model.Colors[i]
94 attrs := "fill=\"#%02x%02x%02x\" fill-opacity=\"%f\""
95 attrs = fmt.Sprintf(attrs, c.R, c.G, c.B, float64(c.A)/255)
96 lines = append(lines, shape.SVG(attrs))
97 }
98 lines = append(lines, "</g>")
99 lines = append(lines, "</svg>")
100 return strings.Join(lines, "\n")
101}
102
103func (model *Model) Add(shape Shape, alpha int) {
104 before := copyRGBA(model.Current)

Callers 1

mainFunction · 0.95

Calls 1

SVGMethod · 0.65

Tested by

no test coverage detected