本文整理匯總了Golang中github.com/gotk3/gotk3/cairo.Context.Rectangle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Rectangle方法的具體用法?Golang Context.Rectangle怎麽用?Golang Context.Rectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gotk3/gotk3/cairo.Context
的用法示例。
在下文中一共展示了Context.Rectangle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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()
}
示例2: 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()
}
}
示例3: 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
}