本文整理匯總了Golang中github.com/BurntSushi/xgbutil/xgraphics.Image.XDrawChecked方法的典型用法代碼示例。如果您正苦於以下問題:Golang Image.XDrawChecked方法的具體用法?Golang Image.XDrawChecked怎麽用?Golang Image.XDrawChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/xgbutil/xgraphics.Image
的用法示例。
在下文中一共展示了Image.XDrawChecked方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updater
func updater(img *xgraphics.Image, win *xwindow.Window) {
//We keep track of times based on 1024 frames
frame := 0
start := time.Now()
var genStart, drawStart time.Time
var genTotal, drawTotal time.Duration
for {
frame = frame + 1
if frame > 1024 {
frame = 0
log.Printf("Time elapsed: %s\n", time.Now().Sub(start))
log.Printf("Time generate: %s\n", genTotal)
log.Printf("Time drawing: %s\n", drawTotal)
start = time.Now()
drawTotal, genTotal = 0, 0
}
genStart = time.Now()
var x, y, i int
for y = 0; y < 768; y++ {
//set last pixel back to black
img.SetBGRA(frame-1, y, xgraphics.BGRA{0, 0, 0, 255})
for i = 0; i < 10; i++ {
x = i + frame
if x > 1024 {
x = 1024
}
img.SetBGRA(x, y, xgraphics.BGRA{0, 0, 255, 255})
}
}
genTotal += time.Now().Sub(genStart)
drawStart = time.Now()
//hopefully using checked will block us from drawing again before x
//draws although XDraw might block anyway, we can check for an error
//here
err := img.XDrawChecked()
if err != nil {
log.Println(err)
return
}
//img.XDraw()
img.XPaint(win.Id)
drawTotal += time.Now().Sub(drawStart)
}
}