Documentation ¶
Overview ¶
Package badge provides an easy way to create SVG badges.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Maker ¶
type Maker struct {
// contains filtered or unexported fields
}
A Maker knows how to make badges.
Example ¶
package main import ( "fmt" "log" "github.com/campoy/svg-badge/badge" "golang.org/x/image/font/gofont/goregular" ) func main() { m, err := badge.NewMaker("Go Regular", goregular.TTF) if err != nil { log.Fatal(err) } b, err := m.New("awesome", "sauce", "fab", 12, 25) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", b) }
Output: <?xml version="1.0"?> <!-- Generated by SVGo --> <svg width="117" height="25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <style type="text/css"> <![CDATA[ text { font-family: Go Regular,Verdana,Geneva,sans-serif; font-size: 12px; fill: white; } ]]> </style> <linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%"> <stop offset="0%" stop-color="#000" stop-opacity="0.00"/> <stop offset="100%" stop-color="#000" stop-opacity="0.25"/> <stop offset="100%" stop-color="#000" stop-opacity="1.00"/> </linearGradient> <rect x="0" y="0" width="117" height="25" rx="5" ry="5" style="fill:#666"/> <rect x="68" y="0" width="49" height="25" rx="5" ry="5" style="fill:#fab"/> <rect x="68" y="0" width="5" height="25" style="fill:#fab"/> <rect x="0" y="0" width="117" height="25" rx="5" ry="5" style="fill:url(#gradient)"/> <text x="8" y="15" >awesome</text> <text x="76" y="15" >sauce</text> </svg>
Click to show internal directories.
Click to hide internal directories.