Documentation
¶
Index ¶
- Constants
- Variables
- func NewFace(size, dpi float64, fontPath string) (face font.Face, err error)
- func NewFaceStream(size, dpi float64, raw []byte) (face font.Face, err error)
- func Render(subject, status string, color Color, fd font.Face, tmpl *fasttemplate.Template) (svg string, err error)
- func RenderDef(subject, status string, color Color) (svg string, err error)
- type Color
Constants ¶
View Source
const ( ColorBrightgreen = Color("brightgreen") ColorGreen = Color("green") ColorYellow = Color("yellow") ColorYellowgreen = Color("yellowgreen") ColorOrange = Color("orange") ColorRed = Color("red") ColorBlue = Color("blue") ColorGrey = Color("grey") ColorGray = Color("gray") ColorLightgrey = Color("lightgrey") ColorLightgray = Color("lightgray") )
Standard colors.
Variables ¶
View Source
var ColorScheme = map[string]string{
"brightgreen": "#4c1",
"green": "#97ca00",
"yellow": "#dfb317",
"yellowgreen": "#a4a61d",
"orange": "#fe7d37",
"red": "#e05d44",
"blue": "#007ec6",
"grey": "#555",
"gray": "#555",
"lightgrey": "#9f9f9f",
"lightgray": "#9f9f9f",
}
ColorScheme contains named colors that could be used to render the badge.
View Source
var FlatTemplate = strings.TrimSpace(`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{{dx}}" height="20">
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<mask id="r">
<rect width="{{dx}}" height="20" rx="3" fill="#fff"/>
</mask>
<g mask="url(#r)">
<rect width="{{subjectDx}}" height="20" fill="#555"/>
<rect x="{{subjectDx}}" width="{{statusDx}}" height="20" fill="{{color}}"/>
<rect width="{{dx}}" height="20" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="{{subjectX}}" y="15" fill="#010101" fill-opacity=".3">{{subject}}</text>
<text x="{{subjectX}}" y="14">{{subject}}</text>
<text x="{{statusX}}" y="15" fill="#010101" fill-opacity=".3">{{status}}</text>
<text x="{{statusX}}" y="14">{{status}}</text>
</g>
</svg>
`)
Functions ¶
func NewFaceStream ¶
NewFaceStream creates a new face based on font bytes, size and dpi
Types ¶
Click to show internal directories.
Click to hide internal directories.