當前位置: 首頁>>代碼示例>>Golang>>正文


Golang draw2d.GraphicContext類代碼示例

本文整理匯總了Golang中github.com/llgcode/draw2d.GraphicContext的典型用法代碼示例。如果您正苦於以下問題:Golang GraphicContext類的具體用法?Golang GraphicContext怎麽用?Golang GraphicContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GraphicContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Main

// Main draws "Hello World" and returns the filename. This should only be
// used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	// Draw hello world
	Draw(gc, fmt.Sprintf("Hello World %d dpi", gc.GetDPI()))

	// Return the output filename
	return samples.Output("helloworld", ext), nil
}
開發者ID:zzn01,項目名稱:draw2d,代碼行數:9,代碼來源:helloworld.go

示例2: drawSnake

func (h *spaceFillingImage) drawSnake(gc draw2d.GraphicContext, snake *draw2d.Path) {
	gc.SetStrokeColor(h.SnakeColor)
	gc.SetLineCap(draw2d.SquareCap)
	gc.SetLineJoin(draw2d.MiterJoin)
	gc.SetLineWidth(2)

	gc.Stroke(snake)
}
開發者ID:google,項目名稱:hilbert,代碼行數:8,代碼來源:demo.go

示例3: UseImageWithContext

// UseImageWithContext specifies both an image
// and a graphic context to create the canvas from.
// The minimum point of the given image
// should probably be 0,0.
func UseImageWithContext(img draw.Image, gc draw2d.GraphicContext) option {
	return func(c *Canvas) uint32 {
		c.img = img
		c.gc = gc
		c.dpi = gc.GetDPI()
		return setsDPI | setsSize
	}
}
開發者ID:zzn01,項目名稱:plot,代碼行數:12,代碼來源:vgimg.go

示例4: lineCircle

func lineCircle(gc d2d.GraphicContext, cx, cy, r float64) {
	count := int(1000.0 * r)

	trace := traceCircle(count, cx, cy, r)

	gc.MoveTo(cx+r, cy)

	for _, pos := range trace {
		gc.LineTo(pos.X, pos.Y)
	}
}
開發者ID:johnny-morrice,項目名稱:amoebethics,代碼行數:11,代碼來源:amoerender.go

示例5: Draw

func (ps *PolygonSymbolizer) Draw(gc draw2d.GraphicContext, shape geom.Shape) {
	if !ps.Applies(shape) {
		return
	}
	if polygon, ok := shape.(geom.PolygonShape); ok {
		gc.SetFillColor(ps.s.Fill)
		for _, path := range polygon.Polygon() {
			l := ps.r.coordsAsPath(path)
			gc.Fill(l)
		}
	}
}
開發者ID:samlecuyer,項目名稱:ecumene,代碼行數:12,代碼來源:symbolizers.go

示例6: draw

func (c squareplot) draw(gc d2d.GraphicContext) {
	for _, cb := range c.boxes {
		gc.SetStrokeColor(black)
		gc.SetFillColor(clear)
		gc.SetLineWidth(1.0)

		side := cb.Radius / 2.0
		lineSquare(gc, cb.P.X, cb.P.Y, side)
		gc.Close()
		gc.FillStroke()
	}
}
開發者ID:johnny-morrice,項目名稱:amoebethics,代碼行數:12,代碼來源:amoerender.go

示例7: 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

示例8: Main

// Main draws vertically spaced lines and returns the filename.
// This should only be used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.SetFillRule(draw2d.FillRuleWinding)
	gc.Clear()
	// Draw the line
	for x := 5.0; x < 297; x += 10 {
		Draw(gc, x, 0, x, 210)
	}
	gc.ClearRect(100, 75, 197, 135)
	draw2d.Ellipse(gc, 148.5, 105, 35, 25)
	gc.SetFillColor(color.RGBA{0xff, 0xff, 0x44, 0xff})
	gc.FillStroke()

	// Return the output filename
	return samples.Output("line", ext), nil
}
開發者ID:stanim,項目名稱:draw2d,代碼行數:17,代碼來源:line.go

示例9: drawRectange

func (h *spaceFillingImage) drawRectange(gc draw2d.GraphicContext, px1, py1, px2, py2 float64) {
	gc.SetFillColor(h.BackgroundColor)
	gc.SetStrokeColor(h.GridColor)
	gc.SetLineWidth(1)

	draw2dkit.Rectangle(gc, px1, py1, px2, py2)
	gc.FillStroke()
}
開發者ID:google,項目名稱:hilbert,代碼行數:8,代碼來源:demo.go

示例10: Plot

func Plot(g draw2d.GraphicContext, points []Point) {
	g.MoveTo(0, 0)
	for _, p := range points {
		g.LineTo(p.x*100, p.y*100)
	}
	g.Close()
	g.FillStroke()
}
開發者ID:taysom,項目名稱:va,代碼行數:8,代碼來源:2d.go

示例11: Main

// Main draws the tiger
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.Save()

	// flip the image
	gc.Translate(0, 200)
	gc.Scale(0.35, -0.35)
	gc.Translate(70, -200)

	// Tiger postscript drawing
	tiger := samples.Resource("image", "tiger.ps", ext)

	// Draw tiger
	Draw(gc, tiger)
	gc.Restore()

	// Return the output filename
	return samples.Output("postscript", ext), nil
}
開發者ID:zzn01,項目名稱:draw2d,代碼行數:19,代碼來源:postscript.go

示例12: Main

// Main draws a left hand and ear of a gopher. Afterwards it returns
// the filename. This should only be used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.Save()
	gc.Scale(0.5, 0.5)
	// Draw a (partial) gopher
	Draw(gc)
	gc.Restore()

	// Return the output filename
	return samples.Output("gopher", ext), nil
}
開發者ID:stanim,項目名稱:draw2d,代碼行數:12,代碼來源:gopher.go

示例13: lineSquare

func lineSquare(gc d2d.GraphicContext, x, y, side float64) {
	xmin, ymin := x-side, y-side
	xmax, ymax := x+side, y+side

	gc.MoveTo(xmin, ymin)
	gc.LineTo(xmin, ymax)
	gc.LineTo(xmax, ymax)
	gc.LineTo(xmax, ymin)
	gc.LineTo(xmin, ymin)
}
開發者ID:johnny-morrice,項目名稱:amoebethics,代碼行數:10,代碼來源:amoerender.go

示例14: 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

示例15: 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


注:本文中的github.com/llgcode/draw2d.GraphicContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。