示例#1
0
// FillString draws a filled and stroked string.
func FillString(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/100, height/100
	gc.Save()
	gc.SetStrokeColor(image.Black)
	gc.SetLineWidth(1)
	draw2dkit.RoundedRectangle(gc, x+sx*5, y+sy*5, x+sx*95, y+sy*95, sx*10, sy*10)
	gc.FillStroke()
	gc.SetFillColor(image.Black)
	gc.SetFontSize(height / 6)
	gc.Translate(x+sx*6, y+sy*52)
	gc.SetFontData(draw2d.FontData{
		Name:   "luxi",
		Family: draw2d.FontFamilyMono,
		Style:  draw2d.FontStyleBold | draw2d.FontStyleItalic})
	w := gc.FillString("Hug")
	gc.Translate(w+sx, 0)
	left, top, right, bottom := gc.GetStringBounds("cou")
	gc.SetStrokeColor(color.NRGBA{255, 0x33, 0x33, 0x80})
	draw2dkit.Rectangle(gc, left, top, right, bottom)
	gc.SetLineWidth(height / 50)
	gc.Stroke()
	gc.SetFillColor(color.NRGBA{0x33, 0x33, 0xff, 0xff})
	gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0xff, 0xff})
	gc.SetLineWidth(height / 100)
	gc.StrokeString("Hug")
	gc.Restore()
}