本文整理汇总了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)
}
}