本文整理匯總了Golang中github.com/llgcode/draw2d.GraphicContext.FillString方法的典型用法代碼示例。如果您正苦於以下問題:Golang GraphicContext.FillString方法的具體用法?Golang GraphicContext.FillString怎麽用?Golang GraphicContext.FillString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/llgcode/draw2d.GraphicContext
的用法示例。
在下文中一共展示了GraphicContext.FillString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FillString
// 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)
draw2d.RoundRect(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})
draw2d.Rect(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()
}
示例2: Draw
// Draw "Hello World"
func Draw(gc draw2d.GraphicContext, text string) {
// Draw a rounded rectangle using default colors
draw2d.RoundRect(gc, 5, 5, 292, 205, 10, 10)
gc.FillStroke()
// Set the font luximbi.ttf
gc.SetFontData(draw2d.FontData{
Name: "luxi",
Family: draw2d.FontFamilyMono,
Style: draw2d.FontStyleBold | draw2d.FontStyleItalic})
// Set the fill text color to black
gc.SetFillColor(image.Black)
gc.SetDPI(72)
gc.SetFontSize(14)
// Display Hello World
gc.SetStrokeColor(color.NRGBA{0x33, 0xFF, 0x33, 0xFF})
gc.MoveTo(8, 0)
gc.LineTo(8, 52)
gc.LineTo(297, 52)
gc.Stroke()
gc.FillString(text)
gc.FillStringAt(text, 8, 52)
gc.Save()
gc.SetFillColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
gc.SetStrokeColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
gc.Translate(145, 85)
gc.StrokeStringAt(text, -50, 0)
gc.Rotate(math.Pi / 4)
gc.SetFillColor(color.NRGBA{0x33, 0x33, 0xFF, 0xFF})
gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0xFF, 0xFF})
gc.StrokeString(text)
gc.Restore()
}