本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xgraphics.Image.SetBGRA方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.SetBGRA方法的具体用法?Golang Image.SetBGRA怎么用?Golang Image.SetBGRA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/BurntSushi/xgbutil/xgraphics.Image
的用法示例。
在下文中一共展示了Image.SetBGRA方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: blendCheckered
// blendCheckered is basically a copy of xgraphics.Blend with no interfaces.
// (It's faster.) Also, it is hardcoded to blend into a checkered background.
func blendCheckered(dest *xgraphics.Image) {
dsrc := dest.Bounds()
dmnx, dmxx, dmny, dmxy := dsrc.Min.X, dsrc.Max.X, dsrc.Min.Y, dsrc.Max.Y
clr1 := xgraphics.BGRA{B: 0xff, G: 0xff, R: 0xff, A: 0xff}
clr2 := xgraphics.BGRA{B: 0xde, G: 0xdc, R: 0xdf, A: 0xff}
var dx, dy int
var bgra, clr xgraphics.BGRA
for dx = dmnx; dx < dmxx; dx++ {
for dy = dmny; dy < dmxy; dy++ {
if dx%30 >= 15 {
if dy%30 >= 15 {
clr = clr1
} else {
clr = clr2
}
} else {
if dy%30 >= 15 {
clr = clr2
} else {
clr = clr1
}
}
bgra = dest.At(dx, dy).(xgraphics.BGRA)
dest.SetBGRA(dx, dy, xgraphics.BlendBGRA(clr, bgra))
}
}
}
示例2: 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)
}
}