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


Golang cairo.Context類代碼示例

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


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

示例1: DrawCallback

func (v *platformView) DrawCallback(area DrawArea, context *cairo.Context) {
	context.Scale(v.parent.Scale(), v.parent.Scale())
	x1, y1, x2, y2 := context.ClipExtents()
	r := image.Rect(int(x1), int(y1), int(x2), int(y2))
	v.drawArch(context, r)
	v.drawChannels(context, r)
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:7,代碼來源:platformview.go

示例2: drawChannels

func (v *mappingView) drawChannels(context *cairo.Context, r image.Rectangle) {
	for _, a := range v.arch {
		for _, pr := range a.Processes() {
			for _, c := range pr.UserObj().OutChannels() {
				link := c.Link()
				lpr := link.Process()
				la := lpr.Arch()
				if la.Name() != a.Name() {
					var a2 graph.ArchIf
					for _, a2 = range v.arch {
						if a2.UserObj() == la {
							break
						}
					}
					p1 := a.ChannelPort(c)
					p2 := a2.ChannelPort(link)
					if p1 == nil || p2 == nil {
						log.Printf("mappingView.drawChannels error: invalid nil port (%s - %s).\n", a.Name(), la.Name())
						continue
					}
					r, g, b, _ := graph.ColorOption(graph.NormalLine)
					context.SetLineWidth(2)
					context.SetSourceRGB(r, g, b)
					pos1 := p1.Position().Add(image.Point{5, 5})
					pos2 := p2.Position().Add(image.Point{5, 5})
					graph.DrawLine(context, pos1, pos2)
				}
			}
		}
	}
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:31,代碼來源:mappingview.go

示例3: DrawCallback

func (v *signalGraphView) DrawCallback(area DrawArea, context *cairo.Context) {
	context.Scale(v.parent.Scale(), v.parent.Scale())
	x1, y1, x2, y2 := context.ClipExtents()
	r := image.Rect(int(x1), int(y1), int(x2), int(y2))
	v.drawNodes(context, r)
	v.drawConnections(context, r)
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:7,代碼來源:signalgraphview.go

示例4: DrawCallback

func (v *mappingView) DrawCallback(area DrawArea, context *cairo.Context) {
	context.Scale(v.parent.Scale(), v.parent.Scale())
	x1, y1, x2, y2 := context.ClipExtents()
	r := image.Rect(int(x1), int(y1), int(x2), int(y2))
	if r.Overlaps(v.unmapped.BBox()) {
		v.unmapped.Draw(context)
	}
	v.drawArch(context, r)
	v.drawNodes(context, r)
	v.drawChannels(context, r)
	v.drawConnections(context, r)
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:12,代碼來源:mappingview.go

示例5: DrawSelector

// draw the piece on the canvas
func (self *MainWindow) DrawSelector(cr *cairo.Context, x, y float64) {

	cr.SetSourceRGBA(0.2, 0.8, 0.2, 0.8)
	cr.SetLineWidth(5)
	cr.Rectangle(x*self.tileWidth, y*self.tileHeight, self.tileWidth, self.tileHeight)
	cr.Stroke()

}
開發者ID:juanfgs,項目名稱:checkers,代碼行數:9,代碼來源:ui.go

示例6: DrawPiece

// draw the piece on the canvas
func (self *MainWindow) DrawPiece(cr *cairo.Context, x, y float64, color []float64) {
	x, y = self.getPiecePosition(x, y)
	x = x + 40
	y = y + 30
	cr.Arc(x, y, 20, 0, 2*3.14)
	cr.SetSourceRGB(color[0], color[1], color[2])
	cr.Fill()
}
開發者ID:juanfgs,項目名稱:checkers,代碼行數:9,代碼來源:ui.go

示例7: cairo_context

func cairo_context(cr *cairo.Context) *C.cairo_t {
	return (*C.cairo_t)(cr.GetCContext())
}
開發者ID:raichu,項目名稱:gotk3,代碼行數:3,代碼來源:pangocairo.go

示例8: drawTable

func drawTable(area *gtk.DrawingArea, cr *cairo.Context, side int, cells []int) {
	u := w.cellSize.GetValue()
	w := area.GetAllocatedWidth()
	h := area.GetAllocatedHeight()
	bg := cellColor[cellPrevious]
	cr.SetSourceRGB(bg[0], bg[1], bg[2])
	cr.Rectangle(1, 1, float64(w-2), float64(h-2))
	cr.Fill()
	for k, cell := range cells[1:] {
		color := cellColor[cell]
		x, y := float64(k/side), float64(k%side)
		cr.SetSourceRGB(color[0], color[1], color[2])
		cr.Rectangle(2+x*u, 2+y*u, u, u)
		cr.Fill()
	}
}
開發者ID:orivej,項目名稱:manual-shuffle,代碼行數:16,代碼來源:main.go

示例9: drawBoard

// Draws and re-draws the board
func (self *MainWindow) drawBoard(da *gtk.DrawingArea, cr *cairo.Context) bool {

	for i := 0; i < self.boardSize; i++ {
		for j := 0; j < self.boardSize; j++ {
			x := float64(j) * self.tileWidth
			y := float64(i) * self.tileHeight

			if (i % 2) == (j % 2) {
				cr.Rectangle(x, y, self.tileWidth, self.tileHeight)
				cr.SetSourceRGB(0.5, 0.3, 0)
				cr.Fill()
			} else {
				cr.Rectangle(x, y, self.tileWidth, self.tileHeight)
				cr.SetSourceRGB(0.2, 0, 0)
				cr.Fill()
			}
		}
	}
	// Draw pieces
	for i, row := range self.Board.Places {
		for j, col := range row {
			if col != nil {
				if col.Selected {
					self.DrawSelector(cr, float64(i), float64(j))
				}
				if col.Team == board.RED {
					self.DrawPiece(cr, float64(i), float64(j), RED)
				} else {
					self.DrawPiece(cr, float64(i), float64(j), BLACK)
				}
			}
		}
	}

	self.drawScores()
	return false
}
開發者ID:juanfgs,項目名稱:checkers,代碼行數:38,代碼來源:ui.go

示例10: DrawAccLine

func DrawAccLine(gc *cairo.Context, x1, y1 float64, p2 image.Point) {
	gc.MoveTo(x1, y1)
	gc.LineTo(float64(p2.X), float64(p2.Y))
	gc.Stroke()
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:5,代碼來源:line.go

示例11: DrawLine

func DrawLine(gc *cairo.Context, p1, p2 image.Point) {
	gc.MoveTo(float64(p1.X), float64(p1.Y))
	gc.LineTo(float64(p2.X), float64(p2.Y))
	gc.Stroke()
}
開發者ID:axel-freesp,項目名稱:sge,代碼行數:5,代碼來源:line.go


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