当前位置: 首页>>代码示例>>Golang>>正文


Golang GraphicContext.FillStringAt方法代码示例

本文整理汇总了Golang中github.com/llgcode/draw2d.GraphicContext.FillStringAt方法的典型用法代码示例。如果您正苦于以下问题:Golang GraphicContext.FillStringAt方法的具体用法?Golang GraphicContext.FillStringAt怎么用?Golang GraphicContext.FillStringAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/llgcode/draw2d.GraphicContext的用法示例。


在下文中一共展示了GraphicContext.FillStringAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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()
}
开发者ID:stanim,项目名称:draw2d,代码行数:35,代码来源:helloworld.go

示例2: drawText

func (h *spaceFillingImage) drawText(gc draw2d.GraphicContext, px1, py1 float64, t int) {
	if !h.DrawText {
		return
	}

	text := strconv.Itoa(t)
	_, top, _, _ := gc.GetStringBounds(text)

	gc.SetFillColor(h.TextColor)
	gc.FillStringAt(text, px1+h.TextMargin, py1-top+h.TextMargin)
}
开发者ID:google,项目名称:hilbert,代码行数:11,代码来源:demo.go

示例3: Draw

// Draw "Hello World"
func Draw(gc draw2d.GraphicContext, text string) {
	// Draw a rounded rectangle using default colors
	draw2dkit.RoundedRectangle(gc, 5, 5, 135, 95, 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.SetFontSize(14)
	// Display Hello World
	gc.FillStringAt("Hello World", 8, 52)
}
开发者ID:zzn01,项目名称:draw2d,代码行数:14,代码来源:helloworld.go

示例4: Draw

func (ts *TextSymbolizer) Draw(gc draw2d.GraphicContext, shape geom.Shape) {
	if !ts.Applies(shape) {
		return
	}
	if name := shape.Attribute(ts.s.Attr); name != "" {
		gc.SetFontSize(ts.s.Size)
		l, t, r, b := gc.GetStringBounds(name)
		bb := shape.Bbox()
		dx := math.Abs(bb[2] - bb[0])
		dy := math.Abs(bb[3] - bb[1])
		ox, oy := dx/2, dy/2

		x, y := ts.r.matrix.TransformPoint(bb[0]+ox, bb[1]-oy)
		gc.SetFillColor(ts.s.Fill)
		gc.FillStringAt(name, x-(r-l)/2, y-(t-b)/2)
	}
}
开发者ID:samlecuyer,项目名称:ecumene,代码行数:17,代码来源:symbolizers.go

示例5: drawText

func drawText(gc draw2d.GraphicContext, text string, x, y float64) {
	var fontSize float64 = 14
	fontSizeHeight := fontSize + 14
	if y < fontSizeHeight {
		return
	}
	gc.SetFontData(draw2d.FontData{Name: "luxi", Family: draw2d.FontFamilyMono, Style: draw2d.FontStyleNormal})
	// Set the fill text color to black

	gc.SetFillColor(image.Black)
	gc.SetFontSize(fontSize)
	// 9px width each letter and 2px letter spacing at font-size 14

	var yPos float64
	for ; yPos < y; yPos = yPos + fontSizeHeight {
		gc.FillStringAt(text, x, yPos)
	}
}
开发者ID:SchumacherFM,项目名称:mediamock,代码行数:18,代码来源:record.go

示例6: DrawHello

// Draw "Hello World"
func DrawHello(gc draw2d.GraphicContext, text string) {
	draw2d.SetFontFolder("static")
	gc.SetFontData(draw2d.FontData{
		Name: "Roboto",
	})

	gc.SetFontSize(14)
	l, t, r, b := gc.GetStringBounds(text)
	//log.Println(t, l, r, b)

	draw2dkit.Rectangle(gc, 0, 0, r-l+30, b-t+30)
	gc.SetFillColor(image.White)
	gc.FillStroke()

	draw2dkit.Rectangle(gc, 10, 10, r-l+20, b-t+20)
	gc.SetFillColor(image.White)
	gc.FillStroke()

	gc.SetFillColor(color.NRGBA{R: 255, G: 0, B: 0, A: 255})
	gc.FillStringAt(text, 15-l, 15-t)

}
开发者ID:Kimau,项目名称:GoDriveTracker,代码行数:23,代码来源:main_test.go


注:本文中的github.com/llgcode/draw2d.GraphicContext.FillStringAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。